#include <bits/stdc++.h>
using namespace std;
const int n = 1e5 + 50;
int N;
int arr[n];
vector<int> V;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", arr + i);
  }
  for (int i = 1; i <= N; i++) {
    auto l = lower_bound(V.begin(), V.end(), arr[i]);
    if (l == V.end()) {
      V.push_back(arr[i]);
    } else {
      *l = min(*l, arr[i]);
    }
  }
  printf("%d", (int)V.size());
}
