#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x;
  scanf("%d", &n);
  map<int, int> mp1;
  map<int, int>::iterator it;
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    mp1[x] = 1;
    it = mp1.find(x);
    it++;
    if (it != mp1.end()) mp1.erase(it);
  }
  cout << mp1.size() << endl;
  return 0;
}
