#include <bits/stdc++.h>
using namespace std;
int p[100100], f[100100];
int main() {
  int res, N, t;
  res = 1;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", p + i);
  memset(f, 0x3f3f3f3f, sizeof(f));
  for (int i = 0; i < N; i++) {
    t = lower_bound(f, f + N, p[i]) - f;
    res = max(res, t + 1);
    f[t] = p[i];
  }
  printf("%d\n", res);
  return 0;
}
