#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> seq;
  int a;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    seq.push_back(a);
  }
  vector<long long> lis;
  lis.push_back(INT_MAX);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < (int)lis.size(); ++j) {
      if (lis[j] >= seq[i]) {
        lis[j] = seq[i];
        break;
      }
      if (j == (int)lis.size() - 1) {
        lis.push_back(seq[i]);
        break;
      }
    }
  }
  cout << lis.size() << endl;
  return 0;
}
