Corners is a game commonly played in the Eastern states of India. It involves 4 or more players, each occupying a corner of a polygon. One player, known as the 'Tat', is chosen and must go to another corner, as directed by a player already occupying a corner. While the 'Tat' is on their way to the redirected corner, the other players try to exchange their spots, and the 'Tat' tries to capture a corner, leaving someone else as the new 'Tat'. This game is similar to Musical Chairs. Mili was playing Corners with her friends and wondered if it's possible for the 'Tat' to get stuck in an infinite loop. She wants to find the loop with the maximum number of corners. Note that a player may redirect the 'Tat' to themselves, creating a loop with a single corner.
The first line of input contains an integer N, representing the number of corners. The next line contains N space-separated integers, each ranging from 0 to N-1. Each integer represents the index or position to which the corresponding player redirects the 'Tat'. Note that each value is unique.
Print the number of corners in the longest loop.
7 5 4 0 3 1 6 2
1 <= N <= 10^5 1 <= A_i < N