#include <bits/stdc++.h>
using namespace std;
int v[100005], h[100005], n;
vector<int> q;
void insert(int i) {
  int val = v[i];
  int lo, mid, hi;
  lo = -1;
  hi = q.size();
  while (hi - lo > 1) {
    mid = lo + (hi - lo) / 2;
    if (val > q[mid])
      lo = mid;
    else
      hi = mid;
  }
  if (hi == q.size()) {
    q.push_back(val);
    h[i] = q.size();
  } else {
    q[hi] = val;
    h[i] = hi + 1;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    insert(i);
  }
  int dim = q.size();
  cout << dim << "\n";
  return 0;
}
