From a permutation P of length N, Alice constructs an array A of length N such that Ai=max(P1,P2,…,Pi). For example, if P=[2,1,3,5,4], then Alice constructs the array A=[2,2,3,5,5].
You are given an array A containing N integers. Find the number of permutations of length N from which Alice can construct the given array A. Since the answer can be very large, print it modulo (109+7).
Input format
Output format
For each test case, print the number of permutations, modulo (109+7) of length N from which the given array A can be constructed.
Constraints
1≤T≤1041≤N≤1051≤Ai≤NSumofNoveralltestcasesdoesnotexceed3⋅105.
Test case 1: The only permutation of length 3 from which Alice can construct A=[1,3,3] is P=[1,3,2].
Test case 2: There is no permutation of length of 4 from which Alice can construct A=[2,2,2,2].
Test case 3: The permutations of length 6 from which Alice can construct A=[2,3,5,5,5,6] are P=[2,3,4,5,4,1,6],P=[2,3,4,5,1,4,6].