Obedient children
Many teachers believe that obedient children are those who regularly attend classes and are punctual for the assembly. However, as PE teachers, we know that true "obedience" is revealed through their behavior during morning exercises. Observing how they conduct themselves in the Coliseum each morning clearly shows who is obedient and who is not.
Obedient children always line up by height, with the tallest student at the front, followed by the next tallest, and so on, until the shortest student is at the end. Fortunately, all students at the Summer Computer School (SCS) have different heights.
Unfortunately, there are also disobedient children—they frequently try to leave their position or even take someone else's spot.
After lining up, I select the K tallest children to participate in a basketball match. However, if due to some disobedient student, the first K students in line do not include the K tallest children of the SCS, I have to announce the lineup repeatedly.
Unable to overcome the disobedient children, I resorted to a clever strategy—I now choose such a K that ensures all K tallest students of the Summer Computer School are among the first K in line.
Help me determine the number of such K.
Input
The first line contains an integer N (1 < N ≤ 100000) - the number of students in the SCS. They are numbered by height, meaning the first is the tallest, and the N-th student is the shortest. The next line contains the order in which they lined up - N integers separated by spaces. All numbers in the line are different and lie within the range [1, N].
Output
Output one number - the answer to the problem.