You are given an array A of length N. Your task is to find the number of permutations of length N from which you can construct the given array A using the following rule:
Since the answer could be a large number, you need to compute it modulo 109+7.
A permutation is a sequence of integers from 1 to N of length N containing each number exactly once. For example, [1],[4, 3, 5, 1, 2],[2,3,1] are permutations and [1, 1],[4, 3, 1],[2, 3, 4] are not.
Input format
Output format
For each test case, print the number of permutations of length N from which you can construct the given array A. Since the answer could be very large, print it modulo 109+7.
Constraints
1≤T≤101≤N≤1051≤A[i]≤N
For test case 1: No permutation satisfies the condition. Hence, the answer is 0.
For test case 2: The only permutation will be [5,4,3,2,1]. Hence, the answer is 1.