#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int main() {
  vector<int> vi;
  int n, f;
  cin >> n >> f;
  vi.push_back(f);
  for (int i = 1; i < (int)n; i++) {
    int in;
    cin >> in;
    if (vi[vi.size() - 1] < in)
      vi.push_back(in);
    else if (in < vi[vi.size() - 1])
      for (int j = 0; j < (int)vi.size(); j++) {
        if (j == vi.size() - 1) vi[j] = in;
        if (vi[j] < in) {
          vi[j - 1] = in;
          break;
        }
      }
  }
  cout << vi.size() << endl;
  return 0;
}
