#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<set> #include<vector> #include<algorithm> using namespace std; const int maxn=1007; const int INF=0x3f3f3f3f; int main() { int n, num; set<int>s; set<int>::iterator it; scanf("%d", &n); while(n--) { scanf("%d", &num); if(s.empty()) s.insert(num); else { it=s.lower_bound(num); if(it==s.end()) s.insert(num); else { s.erase(it); s.insert(num); } } } printf("%d ", s.size()); return 0; }