#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5 + 5);
int a[N], dp[N], t[4 * N], sz;
int max(int l, int r, int L, int R, int v) {
  if (r <= L || R <= l) return 0;
  if (l <= L && R <= r) return t[v];
  int mid = (L + R) / 2;
  return max(max(l, r, L, mid, v * 2), max(l, r, mid, R, v * 2 + 1));
}
void upd(int v, int val) {
  v += sz - 1;
  while (v) {
    t[v] = max(val, t[v]);
    v /= 2;
  }
}
int main() {
  int n, res = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i] = 1;
  }
  sz = 1;
  while (sz < n) sz <<= 1;
  for (int i = 0; i < n; i++) {
    dp[i] = max(1, a[i], 1, sz + 1, 1) + 1;
    res = max(res, dp[i]);
    upd(a[i], dp[i]);
  }
  cout << res << endl;
  return 0;
}
