Money and Hiding Places
Hard
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Input
The first line contains the number of hiding places n (0 < n < 15000). The second line provides a sequence of n integers, each representing the transfer scheme. Here, the i-th integer indicates the hiding place to which the contents of the i-th hiding place are transferred each day.
Output
Output a single integer representing the number of days required for the contents of the hiding places to return to their original configuration.
Examples
Input #1
Answer #1
Submissions 456
Acceptance rate 4%