#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005], n;
int fin(int len, int p) {
  int l, r, mid;
  l = 1, r = len, mid = (l + r) >> 1;
  while (l <= r) {
    if (p > b[mid])
      l = mid + 1;
    else if (p < b[mid])
      r = mid - 1;
    else
      return mid;
    mid = (l + r) >> 1;
  }
  return l;
}
int LIS() {
  int i, j, len = 1;
  b[1] = a[0];
  for (i = 1; i < n; i++) {
    j = fin(len, a[i]);
    b[j] = a[i];
    if (j >= len) len = j;
  }
  return len;
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", a + i);
  printf("%d", LIS());
  return 0;
}
