#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; #define inf 0x3f3f3f3f int N, ans; int dp[maxn], a[maxn], num[maxn]; int main() { scanf("%d", &N); for(int i = 0; i < N; i ++) scanf("%d", &a[i]); fill(dp, dp + N, inf); ans = -1; for(int i = 0; i < N; i ++) { int pos = lower_bound(dp, dp + N, a[i]) - dp; num[i] = pos + 1; ans = max(ans , num[i]); dp[pos] = a[i]; } printf("%d ", ans); return 0; }