#include <bits/stdc++.h>
using namespace std;
int a[100000];
int chang[100000];
int erfen(int shu, int k) {
  int qian = 1;
  int hou = k;
  int mid = (qian + hou) / 2;
  while (qian <= hou) {
    if (chang[mid] > shu) {
      qian = mid + 1;
    } else
      hou = mid - 1;
  }
  return hou;
}
int main() {
  int n;
  int sum = 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    chang[i] = 1;
  }
  chang[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] > chang[sum]) {
      chang[++sum] = a[i];
    } else {
      int pos = erfen(a[i], sum);
      chang[pos] = a[i];
    }
  }
  printf("%d\n", sum);
  return 0;
}
