#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<int, int>& p1, const pair<int, int>& p2) {
  return p1.first < p2.first;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    v.push_back(a);
  }
  vector<int> v1;
  int res = n;
  for (int i = 0; i < n; i++) {
    int idx = upper_bound(v1.begin(), v1.end(), v[i]) - v1.begin();
    if (idx != v1.size()) {
      v1[idx] = v[i];
      res--;
    } else
      v1.push_back(v[i]);
  }
  printf("%d\n", res);
  return 0;
}
