#include <bits/stdc++.h>
using namespace std;
int n, a[100001], f[100001];
int calc(int now) {
  int will = 0;
  for (; now; now -= now & (-now)) will = max(will, f[now]);
  return (will);
}
inline void insert(int x, int y) {
  for (int now = x; now <= n; now += now & (-now)) f[now] = max(f[now], y);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int ans = 0;
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++) {
    int now = calc(a[i] - 1) + 1;
    ans = max(now, ans);
    insert(a[i], now);
  }
  printf("%d\n", ans);
}
