#include<bits/stdc++.h>

#define D(x) cout << "|| " << "at " << __LINE__ << ", " << #x << " = " << (x) << endl
#define ull unsigned long long
#define endl '\n'

using namespace std;

vector<ull> h;

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

    ull N;
    cin >> N;

    ull cnt = 0;

    for (ull i = 0; i < N; i++)
    {
        ull tmp;
        cin >> tmp;
        h.push_back(tmp);
    }

    for (ull i = 0; i < N; i++)
    {
        for (ull j = i + 1; j < N; j++)
        {
            bool a = true;
            for (ull t = i + 1; t < j; t++)
            {

                if (h[t] > h[j] && h[t] > h[i])
                {
                    a = false;
                }
            }
            if (a)
                cnt++;
        }
    }

    cout << cnt;

    return 0;
}
