#include <bits/stdc++.h>
using namespace std;
int n, a[100005], x, ans;
const int inf = 99999999;
int main(int argc, char **argv) {
  while (~scanf("%d", &n)) {
    for (int i = 0; i <= n; ++i) a[i] = inf;
    ans = 0;
    for (int i = 0; i < n; ++i) {
      scanf("%d", &x);
      int p = lower_bound(a, a + n, x) - a;
      a[p] = x;
      ans = max(ans, p);
    }
    printf("%d\n", ans + 1);
  }
  return 0;
}
