#include <bits/stdc++.h>
int n, a[100010], sequence[100010], ind = 1;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sequence[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] > sequence[ind - 1]) {
      sequence[ind++] = a[i];
      continue;
    }
    int ini = 0, fin = ind - 1;
    while (ini < fin) {
      int md = (ini + fin) / 2;
      if (sequence[md] > a[i]) {
        fin = md;
      } else {
        ini = md + 1;
      }
    }
    sequence[ini] = a[i];
  }
  printf("%d", ind);
  return 0;
}
