Given N buckets and infinite number of balls. The maximum capacity of each bucket is given in an array capacity. Find the number of ways to fill the buckets with balls such that each bucket has atleast 1 ball and all the buckets have distinct number of balls in them.
N = 1
capacity = 
Explanation: Since there is only one
bucket.It may hold any number of balls
ranging from 1 to 6.
N = 2
capacity = [5, 8]
Explanation: The first bucket can contain
1 to 5 number of balls whereas second bucket
can be assigned with 2 to 8 number of balls
i,e total there are 35 ways.
You don't need to read or print anything. Your task is to complete the function totalWays() which takes N and capacity as input parameters and returns the number of possible ways to fill the buckets. Since the answer may be very large, calculate the answer modulo 10^9+7.
Expected Time Complexity: O(N) Expected Space Complexity: O(1)