#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1000000000;
int n, a, d[100005];
void update(int x, int a);
int get(int x);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    update(a, get(a - 1) + 1);
  }
  cout << get(n) << "\n";
  return 0;
}
void update(int x, int a) {
  for (; x <= n; x |= x + 1) d[x] = max(d[x], a);
}
int get(int x) {
  int result = 0;
  for (; x > 0; x = (x & (x + 1)) - 1) result = max(result, d[x]);
  return result;
}
