#include <bits/stdc++.h>
#define endl "\n"

using namespace std;
string str(int i)
{
    string res = "";
    do
    {
        res += (char)(i%10+'0');
        i /= 10;
    }while(i != 0);
    reverse(res.begin(),res.end());
    if(res.size() == 1) res = "0" + res;
    return res;
}

const int MAXN = 1e6+5;
int n,h[MAXN];
int g1[MAXN],g2[MAXN];

vector<int>g[MAXN];
ifstream fin;
ofstream fout;

void read()
{
    fin >> n;
    for(int i = 1; i <= n; i++) fin >> h[i];
}

void make_g()
{
    h[0] = h[n+1] = 1e9 + 1;
    stack<int>st;
    st.push(0);
    for(int i = 1; i <= n; i++)
    {
        while(!st.empty() && h[st.top()] <= h[i]) st.pop();
        g1[i] = st.top();
        st.push(i);
    }
    while(!st.empty()) st.pop();

    st.push(n+1);
    for(int i = n; i >= 1; i--)
    {
        while(!st.empty() && h[st.top()] <= h[i]) st.pop();
        g2[i] = st.top();
        st.push(i);
    }
    while(!st.empty()) st.pop();


    for(int i = 1; i <= n; i++)
    {
        g[g1[i]].push_back(i);
        g[g2[i]].push_back(i);
    }

    /*for(int i = 0; i <= n+1; i++)
    {
        cout << i << " ->";
        for(int nb : g[i]) cout << nb << " ";
        cout << endl;
    }*/
}

int dp[MAXN];
int testify;

void dfs(int beg)
{
    if(dp[beg]) return;

    for(int nb : g[beg])
    {
        if(nb < 1 || nb > n) continue;
        dfs(nb);
        dp[beg] = max(dp[beg],dp[nb]);
    }
    dp[beg]++;
    return;
}

void solve(int testi)
{
    testify = testi;
    //if(testi == 28) cout << "bla bla" << endl;
    for(int i = 0; i <= n+1; i++) g[i].clear();///

    for(int i = 0; i <= n+1; i++) dp[i] = 0;
    make_g();

    //if(testi == 28) cout << "blo blo" << endl;
    int ans = 1;
    for(int i = 1; i <= n; i++)
    {
        //if(testi == 28) cout << i << endl;
        if(!dp[i]) dfs(i);
        ans = max(ans,dp[i]);

    }
    //if(testi == 28) cout << ans << endl;
    fout << ans << endl;
}

int main()
{
    for(int i = 1; i <= 50; i++)
    {
        string namein = "test" + str(i) + ".in";
        string nameout = "test" + str(i) + ".out";
        fin.open(namein);
        fout.open(nameout);

        read();
        solve(i);
        fin.close();
        fout.close();
    }

return 0;
}
