#include <bits/stdc++.h>
const double PI = acos(-1);
const double ESP = 1e-10;
const double INF = 1e9;
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> out(1, INF);
  for (int i = 0; i < n; i++) {
    int in;
    cin >> in;
    bool h = false;
    for (int j = 0; j < out.size(); j++)
      if (out[j] >= in) {
        h = true;
        out[j] = in;
        break;
      }
    if (!h) out.push_back(in);
  }
  cout << out.size() << endl;
}
