We are given an array of integers of size ’n’. There is an infinite supply of each integer of the array. Now, for each index in the array, the task is to calculate all the possible ways in which the integer present at that index can be obtained by adding up 3 integers from arr[0], arr[1]…arr[i-1] (considering the calculation is being done for the index ‘i’). Since, there is infinite supply, repetition of one element is allowed, i.e., all the three integers can come from the same index of the array.
Constraints: Size of array could be as large as 10⁵