var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
var N=arr.shift();
var A=[];
var L=[];
for(var i=0;i<N;i++)A.push(arr.shift());
L[0] = A[0]
var length = 1;
for(var i=1;i<N;i++){
   if (L[length-1] < A[i])L[length++] = A[i];
   else {
      for(var j=0;j<length;j++){
         if(L[j]>=A[i]){L[j]=A[i];break;}
      }
   }
}
console.log(length);