#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  const int inf = 1e8;
  int r = 1;
  vector<int> out(n + 1, inf);
  out[0] = -1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = r; i >= 0; j--) {
      if (out[j] < a) {
        out[j + 1] = a;
        r = max(r, j + 1);
        break;
      }
    }
  }
  cout << r << endl;
}
