#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000 + 10;
int n;
int a[MAX];
int sum[MAX];
void add(int a, int b) {
  for (; a < MAX; a += a & (-a)) sum[a] = max(sum[a], b);
}
int ask(int a) {
  int ans = 0;
  for (; a; a -= a & (-a)) ans = max(ans, sum[a]);
  return ans;
}
int main() {
  int i;
  scanf("%d", &n);
  int ans = 0;
  for ((i) = (1); (i) <= (n); ++(i)) {
    scanf("%d", &a[i]);
    int f = ask(a[i]) + 1;
    ans = max(ans, f);
    add(a[i], f);
  }
  printf("%d\n", ans);
  return 0;
}
