#include<bits/stdc++.h>
using namespace std;
vector<int> a;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;i<n;i++) {
        int z;
        cin>>z;
        a.push_back(z);
    }
    int ans=0;
    for(int i=0;i<a.size();i++) {
        int maxHeight=0;
        for(int j=i+1;j<a.size();j++) {
            if(maxHeight<=a[i] || maxHeight<=a[j]) {
                ans++;
               // cout<<i+1<<" "<<j+1<<endl;
            }
            maxHeight=max(maxHeight,a[j]);
        }
    }
    cout<<ans;
    return 0;
}
