#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, len, priv, cur;
  vector<int> v;
  vector<int>::iterator low;
  len = 0;
  priv = 0;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    cin >> cur;
    if (cur > priv) {
      v.push_back(cur);
      len++;
    } else {
      low = lower_bound(v.begin(), v.end(), cur);
      v.insert(low + 1, cur);
    }
    priv = *(v.end() - 1);
  }
  cout << len << endl;
}
