#include <bits/stdc++.h>
using namespace std;
struct node
{
vector<int>l;
int n;
};
vector<int>a;
int maxn=INT_MIN,n;
void bfs()
{
queue<node>q;
node h,t;
for(int i=0;i<a.size();i++)
{
h.l.clear();
h.l.push_back(a[i]);
h.n=i;
q.push(h);
}
while(!q.empty())
{
h=q.front(),q.pop();
if(h.n==n) maxn=max(maxn,int(h.l.size()));
if(a[h.n+1]<=h.l[h.l.size()-1])
{
t.l=h.l,t.n=h.n+1;
while(a[t.n]<=t.l[t.l.size()-1])
{
t.l.pop_back();
}
t.l.push_back(a[t.n]);
q.push(t);
t.l=h.l,t.n=h.n+1;
q.push(t);
}
else
{
t.l=h.l,t.n=h.n+1;
t.l.push_back(a[t.n]);
q.push(t);
}
}
}
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
bfs();
cout<<maxn;
return 0;
}