#include<stdio.h>
#define LARGE 100000

int main(){
	int i,j,n;
	int max;
	int allmax=-1;
	int a[LARGE];
	int d[LARGE]={0};
	
	scanf("%d",&n);
	d[0]=1;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		max=0;
		for(j=0;j<i;j++){
			if(a[j]<a[i] && d[j]>max){
				max=d[j];
			}
		}
		d[i]=max+1;
		if(allmax < d[i])allmax=d[i];
	}

	printf("%d\n",allmax);
	
	return 0;
}
