#include <bits/stdc++.h>
using namespace std;
int n, ans;
int ar[100003];
int tree[4 * 100003];
int Query(int cx, int cy, int qx, int qy, int pos) {
  if (cy < qx || qy < cx) return 0;
  if (qx <= cx && cy <= qy) return tree[pos];
  int mid = (cx + cy) >> 1;
  return max(Query(cx, mid, qx, qy, pos * 2),
             Query(mid + 1, cy, qx, qy, pos * 2 + 1));
}
void Update(int cx, int cy, int q, int val, int pos) {
  if (cy < q || q < cx) return;
  tree[pos] = max(tree[pos], val);
  if (cx == cy) return;
  int mid = (cx + cy) >> 1;
  Update(cx, mid, q, val, pos * 2);
  Update(mid + 1, cy, q, val, pos * 2 + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &ar[i]);
  for (int i = 1; i <= n; i++) {
    int tmp = Query(1, n, 1, ar[i], 1) + 1;
    Update(1, n, ar[i], tmp, 1);
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}
