//用q来储存每个长度尾的最小值
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
const int N=100010;
int q[N],a[N];
int main(){
int n;
scanf(“%d”,&n);
for(int i=1;i<=n;i++) scanf(“%d”,&a[i]);
int len=0;
q[0]=-1e6;
for(int i=1;i<=n;i++){
int l=0,r=len;
while(l<r){
int mid=l+r+1>>1;
if(q[mid]<a[i]) l=mid;
else r=mid-1;
}
len=max(len,r+1);
q[r+1]=a[i];
}
cout<<len;
return 0;
}