// Solitaire LIS
#include <algorithm>
#include <cstdio>
using namespace std;

int decks[100010];
int main() {
  fill(decks, decks + 100010, 1 << 31);
  int n, ndecks = 0;
  scanf("%d", &n);
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    int k = lower_bound(decks, decks + ndecks, x) - decks;
    decks[k] = x;
    ndecks = max(ndecks, k + 1);
  }
  printf("%d\n", ndecks);
}
