#include <bits/stdc++.h>
using namespace std;
int it[200041], n, io;
int down(int x) {
  int s = 0, rs = x;
  while (x <= n * 2) {
    s = max(it[x], s);
    x += x & (-x);
  }
  return s;
}
void up(int x, int u) {
  while (x > 0) {
    it[x] = max(it[x], u);
    x -= x & (-x);
  }
}
int main() {
  int i, a[100005], o = 0, co;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = n - 1; i >= 0; i--) {
    co = down(a[i]);
    up(a[i], co + 1);
    o = max(co + 1, o);
  }
  cout << o << endl;
}
