Order of a permutation#1789

Order of a permutation

1 second
128 megabytes
Medium

Find the order of a permutation .

A permutation of elements is an ordered sequence of distinct integers from to .

The order of a permutation is the smallest positive integer such that p^k = \varepsilon, where is the identity permutation (1, 2, \ldots, n).

Input

The first line contains a positive integer (0 < n \leq 100), the size of the permutation . The second line contains the permutation , represented as a sequence of integers.

Output

Print the order of the given permutation.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading