#include <stdio.h>

int main(void) {
	int n; scanf("%d",&n);
	int ary[n];
	
	int bry[n];
	int length = 0;
	for (int i=0; i<n; i++) {
		bry[i] = -1;
		scanf("%d",&ary[i]);
		int k = 0;
		while (bry[k] >= ary[i]) k++;
		if (bry[k] == -1) length++;
		bry[k] = ary[i];
	}
	printf("%d\n",length);
	
	return 0;
}
