Consider the bubble sort algorithm:
for i = 1 to n do
for j = 1 to n - 1 do
if(p[j] > p[j + 1])
swap(p[j], p[j+1])
Let denote
You are given an permutation
Input Specification
The first line contains an integer
For each test case,
- The first line contains an integer
, which is the length of the permutation. - The second lines contains
integers in the permutation.
Output Specification
For each test case, output the answer under modulo
Constraints
For all test file,
Sample 1 Input
1
3
1 3 2
Sample 1 Output
3
Sample 1 Explanation
All permutation lexicographically larger than "
Sample 2 Input
1
4
1 4 2 3
Sample 2 Output
9
Subtask
For all data,
Denote
test point | special properties | ||
---|---|---|---|
1 | None | ||
2 | none | ||
3 | None | ||
4 | None | ||
5 | None | ||
6 | None | ||
7 | None | ||
8 | None | ||
9 | None | ||
10 | None | ||
11 | None | ||
12 | |||
13 | None | ||
14 | None | ||
14 | None | ||
16 | None | ||
17 | |||
18 | None | ||
19 | None | ||
20 | None | ||
21 | |||
22 | none | ||
23 | None | ||
24 | None | ||
25 | none |
Comments