#include <bits/stdc++.h>
using namespace std;
set<int> myset;
int main(int argc, char** argv) {
  int n, x;
  cin >> n;
  auto it = myset.begin();
  for (int i = 0; i < n; i++) {
    cin >> x;
    myset.insert(x);
    it = myset.find(x);
    it++;
    if (it != myset.end()) myset.erase(it);
  }
  cout << ((int)(myset).size()) << endl;
  return 0;
}
