There is a sorted array $[1,2,\dots,n]$ and a permutation $p_1,p_2,\dots,p_n$ . On each round, all elements move according to the permutation: the element at position $i$ moves to position $p_i$ .
After how many rounds is the array sorted again for the first time?
The first line has an integer $n$ .
The next line contains $n$ integers $p_1,p_2,\dots,p_n$ .
Print the number of rounds modulo $10^9+7$ .
8 5 3 2 6 4 1 8 7
\n · · · · · · · \n
4
\n