Degree of a permutation
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Find the degree of a permutation .
A permutation of elements is an ordered set of distinct numbers from to .
The degree of a permutation is a minimal positive integer such that , where is an identity permutation .
Input
The first line contains the order of a permutation . The second line contains the permutation itself.
Output
Print the degree of the given permutation.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 797
Acceptance rate 61%