#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], l[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  l[0] = a[0];
  int p = 0;
  for (int i = 1; i < n; i++) {
    if (l[p] < a[i])
      l[++p] = a[i];
    else {
      int left = 0, right = p, m = 0;
      while (left + 1 < right) {
        m = (left + right) / 2;
        if (l[m] > a[i])
          right = m;
        else
          left = m;
      }
      l[m] = a[i];
    }
  }
  cout << p + 1 << endl;
  return 0;
}
