#include<bits/stdc++.h>
using namespace std;
int a[1001][4];
int m,n,ans;
int main()
{ freopen("lis1.in","r",stdin);
freopen("lis1.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++)
{ scanf("%d",&a[i][1]);
a[i][2]=1;
}
for (int i=n-1;i>=1;i--)
{ int l=0,k=0;
for (int j=i+1;j<=n;j++)
if (a[i][1]<a[j][1]&&a[j][2]>l)
{ l=a[j][2];
k=j;
}
if (l>0) a[i][2]=l+1;
}
for (int i=1;i<=n;i++)
ans=max(ans,a[i][2]);
printf("%d",ans);
return 0;
}