There are N buckets. The task is to assign a certain number of balls to each bucket. Each bucket should have atleast one ball. The capacity of each bucket is provided in an array MAX. For the ith bucket, the capacity is MAX[i] and the number of balls to be assigned to the ith bucket is between 1 to MAX[i] both bounds inclusive. All buckets should have distinct number of balls. Output "the number of ways in which the N buckets can be filled" modulo 109+7.
First line of the input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case consists of an integer - N denoting the number of buckets. Second line of each test case consists of N space separated integers of array MAX denoting the maximum cappacity of each bucket.
For each test case, output the required answer in a separate line.
1 ≤ T ≤ 20
1 ≤ N ≤ 1000
1 ≤ MAX[k] ≤ 1000 for k=1,2..N
For the first example, the single bucket can be assigned any number between 1 and 6, inclusive, hence 6 ways.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.