#include <bits/stdc++.h>
constexpr int INF_I = std::numeric_limits<int>::max();
constexpr int MAX_N = 100000;
int main() {
  int N;
  int L[MAX_N], length = 1;
  std::fill(L, L + MAX_N, INF_I);
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int A;
    scanf("%d", &A);
    if (L[length - 1] < A) {
      L[length] = A;
      ++length;
    } else {
      *std::upper_bound(L, L + length, A) = A;
    }
  }
  printf("%d\n", length);
  return 0;
}
