Given a sequence Ai consisting of N integers. Find the number of pairs (L, R) for which the subsegment {AL, AL + 1, ..., AR} is a permutation of R - L + 1 numbers.
A permutation of K numbers is any sequence of numbers from 1 to K, where each element occurs only once.
The first line contains number N — a sequence length. The second line contains N integers — sequence Ai elements.
Print the number of pairs (L, R), fulfilling the condition.
3
3 1 2
3
| Name |
|---|


