- Time limit: 2.00 s
- Memory limit: 512 MB
There are 4n tourists, numbered 1,2,\dots,4n, who want to get to the top of a mountain using gondolas. The tourists have been divided into n groups of 4 people. Group 1 consists of tourists 1 \dots 4, group 2 consists of tourists 5 \dots 8, and so on.
Each group leaves immediately when all members of the group have arrived at the gondola station. You are given the arrival order of the tourists, and your task is to find out which group leaves first.
Input
The first line has an integer n: the number of groups.
The second line has 4n integers: the arrival order of the tourists. The i'th integer is the index of the i'th tourist to arrive.
Output
Print the number of the first group that leaves.
Constraints
- 1 \leq n \leq 10^{5}
Example
Input:
2 1 6 3 7 8 2 5 4
Output:
2
Explanation: Group 2 leaves first when tourist 5 has arrived.