Hi, can someone help me solve this problem:
Input consist of integer n and array a of n integers. Output number of pairs (a[i],a[j]), i<j who are adjacent or for all k (i<k<j) this equation is true: a[k]<=min(a[i],a[j]).
1<=n<=10^6
0<=a[i]<=2^31
example:
8
4 1 2 3 6 5 1 2
Output: 11