#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009, maxn = 400000;
const long long INF = 1000000000ll * 1000000000ll;
int rmq[maxn << 2];
int n;
void insert(int i, int w) {
  int id = 1, l = 0, r = n, m;
  while (l < r) {
    m = (l + r) / 2;
    id *= 2;
    if (i <= m)
      r = m;
    else
      l = m + 1, ++id;
  }
  rmq[id] = w;
  id /= 2;
  while (id >= 1) {
    rmq[id] = max(rmq[id * 2], rmq[id * 2 + 1]);
    id /= 2;
  }
}
int maxf(int i, int l, int r, int nl, int nr) {
  if (r < nl || nr < l || l > r) return 0;
  if (nl <= l && r <= nr) return rmq[i];
  int m = (l + r) / 2;
  return max(maxf(i * 2, l, m, nl, nr), maxf(i * 2 + 1, m + 1, r, nl, nr));
}
int L, d, af;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &af);
    int tmp = maxf(1, 0, n, 0, af - 1) + 1;
    insert(af, tmp);
  }
  cout << rmq[1] << endl;
}
