Find the degree of a permutation p.
A permutation of n elements is an ordered set of n distinct numbers from 1 to n.
The degree of a permutation p is a minimal positive integer k such that pk=ε, where ε is an identity permutation (1,2,...,n).
The first line contains the order n (0<n≤100) of a permutation p. The second line contains the permutation p itself.
Print the degree of the given permutation.