#include <iostream>
using namespace std;
int a[1000000];
int main()
{
    int n, l, r, br = 0;
    cin >> n;
    for ( int i = 0; i < n; i++ )
    {
        cin >> a[i];
    }
    for ( int i = 0; i < n - 1; i++ )
    {
        int razl = a[i+1];
        for ( int j = i + 1; j < n; j++ )
        {
            ///cout << razl << " ";
            if (  a[j] >= razl || razl <= a[i] )
            {
                br++;
                razl = max(razl,a[j]);
                ///cout << i + 1 << " " << j + 1 << endl;
            }
        }
    }
    cout << br << endl;
    return 0;
}
/**

*/
