#include<bits/stdc++.h> #include<iostream> using namespace std; const int N = 1e5 +5; int n,a[N]; vector<int>v; int main() { cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; v.push_back(a[1]); for(int i=2;i<=n;i++) { if(a[i]>v.back()) v.push_back(a[i]); else *lower_bound(v.begin(),v.end(),a[i])=a[i]; } cout<<v.size(); return 0; }