#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, a[N], t[N], sol;
void upd(int i, int v) {
  for (; i <= n; i += i & -i) t[i] = max(t[i], v);
}
int get(int i) {
  int s = 0;
  for (; i; i -= i & -i) s = max(s, t[i]);
  return s;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int x = get(a[i] - 1) + 1;
    sol = max(sol, x);
    upd(a[i], x);
  }
  printf("%d\n", sol);
  return 0;
}
