| Homs Collegiate Programming Contest 2026 |
|---|
| Закончено |
You are given an array $$$a$$$ of length $$$n$$$.
A permutation $$$p$$$ of length $$$n$$$ is called good if for each $$$i$$$ from $$$1$$$ to $$$n$$$ the following condition holds:
Find the number of good permutations modulo $$$10^9 + 7$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t (1 \le t \le 5 \cdot 10 ^ 4)$$$. The description of the test cases follows.
The first line of each test case contains the integer $$$n (1 \le n \le 3 \cdot 10 ^ 5)$$$.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\dots,a_n (1 \le a_i \le n)$$$.
It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$3 \cdot 10^5$$$.
For each test case, output one integer: the answer modulo $$$10 ^ 9 + 7$$$.
331 1 131 2 352 1 2 1 2
6348
In the third test case the permutation $$$[3, 2, 1, 4, 5]$$$ is good because :
| Название |
|---|


