#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, a;
  vector<int> L(100000);
  int l = 0;
  cin >> n;
  cin >> a;
  L[0] = a;
  for (int i = 1; i < n; i++) {
    cin >> a;
    vector<int>::iterator pos = lower_bound(L.begin(), L.end(), a);
    if (i == 1 && a == 0) {
      l++;
    } else if (pos == L.end()) {
      L.push_back(a);
      l++;
    } else {
      pos = L.erase(pos);
      L.insert(pos, a);
    }
  }
  cout << l << endl;
}
