#include<bits/stdc++.h>
using namespace std;
unsigned int n, h[2000005];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i=0; i<n; i++) cin >> h[i];

    int br = 0, mx;
    for(int i=0; i<n-1; i++) {
        br++;//cout << i+1 << " " << i+2 << endl;
        mx = h[i+1];

        for(int j=i+2; j<n; j++) {
            //if(h[i]<mx) break;
            if(h[i]>=mx || h[j]>=mx) {
                br++;//cout << i+1 << " " << j+1 << endl;
                mx = h[j];
            }
        }
    }

    cout << br << endl;
    return 0;
}
