#include <bits/stdc++.h>
using namespace std;
int n, i, x, b[110000];
void modify(int x, int y) {
  for (; x <= n; x += x & -x) b[x] = ((b[x]) > (y) ? (b[x]) : (y));
}
int get(int x) {
  int ans = 0;
  for (; x; x -= x & -x) ans = ((ans) > (b[x]) ? (ans) : (b[x]));
  return ans;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    modify(x, get(x) + 1);
  }
  printf("%d\n", get(n));
}
