#include <bits/stdc++.h>
using namespace std;
int a[100010], v[100010];
int main() {
  int i, n, len;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  len = 1;
  v[0] = a[0];
  for (i = 1; i < n; i++) {
    int pt = lower_bound(v, v + len, a[i]) - v;
    if (pt == len) {
      v[len++] = a[i];
    } else {
      v[pt] = a[i];
    }
  }
  cout << len << endl;
  return 0;
}
