#include <bits/stdc++.h>
const int N = 100005;
int subseq(int n, const int *a) {
  static int b[N + 1];
  int i, l, r, m, ret = 0;
  for (i = 0; i < n; b[l] = i++, ret += (l > ret)) {
    for (m = ((l = 1) + (r = ret)) >> 1; l <= r; m = (l + r) >> 1) {
      if (((a[b[m]]) < (a[i]))) {
        l = m + 1;
      } else {
        r = m - 1;
      }
    }
  }
  return ret;
}
int n, a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  printf("%d\n", subseq(n, a));
}
