#include <bits/stdc++.h>
using namespace std;
long long n, sz, i, ans, j, a[200001], t[531172], op;
void upd(int x) {
  for (j = x / 2; j >= 1; j /= 2) t[j] = max(t[j * 2], t[j * 2 + 1]);
}
long long finds(int l, int r) {
  long long sum = -1;
  while (l <= r) {
    if (l % 2 == 1) sum = max(sum, t[l]);
    if (r % 2 == 0) sum = max(sum, t[r]);
    l++, r--, l /= 2, r /= 2;
  }
  return sum;
}
int main() {
  cin >> n;
  sz = 1;
  while (sz < n) sz *= 2;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    t[a[i] + sz - 1] = finds(sz, a[i] + sz - 1) + 1;
    upd(a[i] + sz - 1);
  }
  cout << max(t[1], 1ll);
}
