#include <iostream>
#include <cstring>
#define N 10005
using namespace std;
int a[N],b[N],n,maxlen=1;
int f( int x)
{ int i,m,t;
if ( b[x]>0 ) return b[x];
m=1;
for (i=0;i<x; i++)
{ t=f(i);
if (a[x]>a[i]) m=max(m,f(i)+1);
if (m>maxlen) maxlen=m;
}
return b[x]=m;
}
int main(int argc, char *argv[])
{ int i,j;
cin>>n;
for (i=0;i<n; i++)
cin>>a[i];
memset(b,-1,sizeof(b) );
f(n-1);
for (i=0;i<n; i++)
if (b[i]>maxlen) maxlen=b[i];
cout<<maxlen<<endl;
return 0;
}
#include <iostream>
#include <cstring>
#define N 10005
using namespace std;
int a[N],b[N],n,maxlen=1;
int f( int x)
{ int i,m,t;
if ( b[x]>0 ) return b[x];
m=1;
for (i=0;i<x; i++)
{ t=f(i);
if (a[x]>a[i]) m=max(m,f(i)+1);
if (m>maxlen) maxlen=m;
}
return b[x]=m;
}
int main(int argc, char *argv[])
{ int i,j;
cin>>n;
for (i=0;i<n; i++)
cin>>a[i];
memset(b,-1,sizeof(b) );
f(n-1);
cout<<maxlen<<endl;
return 0;
}