#include <bits/stdc++.h>
int n = 0;
int plc[100008];
int bit[100008];
void add(int x, int vl) {
  int k = 1;
  while (x <= n) {
    if (x & k) {
      if (bit[x] < vl) bit[x] = vl;
      x += k;
    }
    k += k;
  }
}
int calc(int x) {
  int ret = 0;
  int k = 1;
  while (x) {
    if (x & k) {
      if (bit[x] > ret) ret = bit[x];
      x -= k;
    }
    k += k;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int as;
    scanf("%d", &as);
    plc[as] = i;
  }
  int sol = 0;
  for (int i = 1; i <= n; i++) {
    int ksol = calc(plc[i] - 1) + 1;
    if (sol < ksol) sol = ksol;
    add(plc[i], ksol);
  }
  printf("%d\n", sol);
  return 0;
}
