#include <bits/stdc++.h>
int N, l, r, now;
int a[100010];
int main() {
  scanf("%d", &N);
  a[0] = 10000000;
  now = 0;
  for (int i = 0, c; i < N; i++) {
    scanf("%d", &c);
    l = 0;
    r = now;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (c >= a[mid])
        l = mid + 1;
      else
        r = mid;
    }
    if (a[l] <= c) l++;
    a[l] = c;
    if (l > now) now = l;
  }
  printf("%d\n", now + 1);
  return 0;
}
