#include<stdio.h>
#include<string.h>
int n;
int p[100000];
int dp[100000];
int main()
{
int i,j,k;
while(scanf("%d",&n)!=EOF){
for(i=1;i<=n;i++)
scanf("%d",&p[i]);
memset(dp,0,sizeof(dp));
dp[1]=1;
int max=0;
for(i=2;i<=n;i++){
int a=0;
for(j=1;j<i;j++)
if(dp[j]>a && p[i]>p[j])
a=dp[j];
dp[i]=a+1;
if(dp[i]>max)
max=dp[i];
}
printf("%d\n",max);
}
}