#include<bits/stdc++.h> usingnamespace std; #define int long long intread() { int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; }
constint N = 1e5 + 10;
int a[N];
signedmain() { int n = read(); int res = 0; for(int i = 1; i <= n; i++) { int x = read(); auto k = upper_bound(a + 1, a + res + 1, x, greater<int>()) - a; if(k > res) a[++res] = x; else a[k] = x; } cout << res << endl; return0; }