Given a permutation of the integers
to
, find the number of subarrays that satisfy the following property:
- If the maximum element it contains is
, then it contains all of the integers
to
Input Specification
The first line will contain .
The following line will contain integers
for
.
Output Specification
Output the number of subarrays with the described property.
Constraints
The given are guaranteed to form a permutation of the integers
to
.
Sample Input 1
1
1
Sample Output 1
1
Sample Input 2
2
2 1
Sample Output 2
2
Sample Input 3
3
1 3 2
Sample Output 3
2
Comments