#include <bits/stdc++.h>
using namespace std;
int n, a[100000 + 5];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int lmax = 0, l;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    vector<int>::iterator it;
    it = lower_bound(v.begin(), v.end(), a[i]);
    l = (it - v.begin() + 1);
    lmax = max(lmax, l);
    if (it == v.end()) {
      v.push_back(a[i]);
    } else {
      *it = a[i];
    }
  }
  cout << lmax << endl;
  return 0;
}
