Junji has found a beautiful tree lying on the ground, and he wants to take it home to beautify his house. However, he only plans on taking a segment of the tree because he has aichmophobia and too many branches scares him.
The tree has
Input Specification
The first line will contain the integer
The second line will contain
The next
It is guaranteed that there is exactly one path between any two connection points.
Output Specification
Output the number of connection points in the longest good segment in the tree.
Constraints
Subtask 1 [10%]
All connection points satisfy the constraint
Subtask 2 [20%]
Subtask 3 [70%]
No additional constraints.
Sample Input 1
7
6 2 30 20 90 42 2
1 2
2 3
3 4
3 5
2 6
2 7
Sample Output 1
4
Sample Input 2
8
2 9999999900000000 3 3 3 3 3 1
1 2
1 3
3 4
4 5
3 6
2 7
2 8
Sample Output 2
2
Comments