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

using namespace std;

const int MAXN = 2e5+5;
int n,h[MAXN];
int g1[MAXN],g2[MAXN];

vector<int>g[MAXN];

void read()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for(int i = 1; i <= n; i++) cin >> 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];

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

    for(int nb : g[beg])
    {
        dfs(nb);
        dp[beg] = max(dp[beg],dp[nb]);
    }
    dp[beg]++;
    return;
}

void solve()
{
    make_g();

    int ans = 1;
    for(int i = 1; i <= n; i++)
    {
        if(!dp[i]) dfs(i);
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;
}

int main()
{

	read();
	solve();
    return 0;
}
