#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int main(int argc,char * argv[]){
int n;
while(scanf("%d",&n)!=EOF){
int i,j;
int len[n];
for(i=0;i<n;++i) scanf("%d",&len[i]);
int log[n];//记录每队队尾的数
int sum=0;
log[0]=len[0];
for(i=1;i<n;++i){
for(j=0;j<=sum;++j){
if(len[i]<=log[j]){log[j]=len[i];break;}//比已有队列的队尾小,插入
else if(j==sum){++sum;log[sum]=len[i];break;}//找不到合适队列,新建
}
}
printf("%d\n",sum+1);
}
return 0;
}