#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
const int MAX = 131072;
const int TREE = 262144;
int n;
int a[MAX];
int tree[TREE];
void update(int idx, int val) {
  idx += (TREE >> 1);
  while (idx) {
    tree[idx] = max(tree[idx], val);
    idx >>= 1;
  }
}
int query(int idx) {
  idx += (TREE >> 1);
  int ret = tree[idx];
  bool flag = !(idx & 1);
  idx >>= 1;
  while (idx) {
    if (flag) ret = max(ret, tree[(idx << 1) + 1]);
    flag = !(idx & 1);
    idx >>= 1;
  }
  return ret;
}
int lis() {
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    int cur = query(a[i] + 1) + 1;
    ans = max(ans, cur);
    update(a[i], cur);
  }
  return ans;
}
int main(void) {
  in = stdin;
  out = stdout;
  fscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) fscanf(in, "%d", &a[i]);
  fprintf(out, "%d\n", lis());
  return 0;
}
