문제
Farmer John has come up with a new morning exercise routine for the cows (again)!
As before, Farmer John's
Given a permutation
A of lengthN , the cows change their order such that thei -th cow from the left before the change isA_i -th from the left after the change.
For example, if
0 steps:
(1,2,3,4,5) 1 step:
(3,1,2,5,4) 2 steps:
(2,3,1,4,5) 3 steps:
(1,2,3,5,4) 4 steps:
(3,1,2,4,5) 5 steps:
(2,3,1,5,4) 6 steps:
(1,2,3,4,5)
Find the sum of all positive integers
As this number may be very large, output the answer modulo
SCORING:
Test cases 2-5 satisfy
N\le 10^2 .Test cases 6-10 satisfy no additional constraints.
Problem credits: Benjamin Qi
입력
The first line contains
출력
A single integer.
예제1
5
100000000721
There exist permutations that cause the cows to take