- Time limit: 1.00 s
- Memory limit: 512 MB
There are fishers numbered scattered around a round lake. Each of the fishers has picked a fixed point on the shoreline and is casting their line to that exact direction. Check if there is a risk of the lines getting tangled up. Tangling may only happen when two lines cross each other.
The fishers and their line casting directions are represented in the array of integers. If the -th integer of is then it means that position is occupied by fisher and if it is then this is the point to which the fisher is casting their line. Positions and are next to each other and as the lake is round, consider positions and to be next to each other also.
Input
The first line contains a single integer . The second line contains integers .
Output
Print "Yes" if the lines might get tangled up and "No" otherwise.
Constraints
- if
Example 1
Input:
5 -1 -4 5 3 2 -5 1 4 -3 -2
Output:
Yes
Example 2
Input:
5 -2 4 -4 2 3 1 5 -5 -1 -3
Output:
No