Given a permutation of number from 1 to N. Among all the subarrays, find the number of unique pairs such that and a is maximum and b is second maximum in that subarray.
Input:
First line contains an integer, N . Second line contains N space separated distinct integers, , denoting the permutation.
Output:
Print the required answer.
All the possible subarrays are:
1
2
3
4
5
The 4 unique pairs are: