#include <bits/stdc++.h>
using namespace std;
int a[111111], b[111111], len;
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  len = 1;
  b[0] = a[0];
  int tmp;
  for (i = 1; i < n; i++) {
    if (a[i] > b[len - 1])
      b[len++] = a[i];
    else {
      tmp = lower_bound(b, b + len, a[i]) - b;
      b[tmp] = a[i];
    }
  }
  printf("%d\n", len);
  return 0;
}
