#include<bits/stdc++.h>
using namespace std;

int a[2000001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin>>n;
    for(int i = 0; i < n; ++i) {
        cin>>a[i];
    }

    long long ans = 0;
    for(int i = 0; i < n-1; ++i) {
        int biggest = -1;
        for(int j = i + 1; j < n; ++j) {
            if(a[j] > biggest) biggest = a[j];
            if(a[i] >= biggest || a[j] >= biggest) {
                ans++;
            }
        }
    }

    cout<<ans<<endl;


    return 0;
}
