#include <bits/stdc++.h>
using namespace std;
int c[100010], n, a[100010];
int lowbit(int x) { return x & (-x); }
void update(int x, int val) {
  for (int i = x; i; i -= lowbit(i)) c[i] = max(c[i], val);
}
int qmax(int x) {
  int ret = 0;
  for (int i = x; i <= n; i += lowbit(i)) ret = max(ret, c[i]);
  return ret;
}
int main() {
  int k, ans;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(c, 0, sizeof(c));
  ans = 0;
  for (int i = n; i >= 1; i--) {
    k = qmax(a[i]);
    ans = max(ans, k + 1);
    update(a[i], k + 1);
  }
  cout << ans << endl;
}
