#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int tree[4 * N];
int a[N];
void update(int node, int s, int e, int p, int val) {
  if (s > p or e < p) return;
  if (s >= p and e <= p) {
    tree[node] = val;
    return;
  }
  int mid = (s + e) / 2;
  update(2 * node, s, mid, p, val);
  update(2 * node + 1, mid + 1, e, p, val);
  tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}
int get(int node, int s, int e, int l, int r) {
  if (l > e or r < s) return 0;
  if (s >= l and e <= r) {
    return tree[node];
  }
  int mid = (s + e) / 2;
  int left = get(2 * node, s, mid, l, r);
  int right = get(2 * node + 1, mid + 1, e, l, r);
  return max(left, right);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cur = get(1, 1, n, 1, a[i] - 1) + 1;
    ans = max(ans, cur);
    update(1, 1, n, a[i], cur);
  }
  printf("%d\n", ans);
  return 0;
}
