#include <bits/stdc++.h>
using namespace std;
int n;
long long st[100010], top, ans, h;
int main(){
//freopen("input.txt", "r", stdin);
scanf("%d", &n);
st[0] = 1e9 + 10, top = ans = 0;
for(int i = 1; i <= n; i++){
scanf("%lld", &h);
while(st[top] <= h) top--;
ans += top;
st[++top] = h;
}
cout << ans << endl;
return 0;
}
12-02
1275
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-23
414
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-06
950
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-10
397
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-24
133
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-27