#include <bits/stdc++.h>
using namespace std;
int a[100000];
int l[100000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    l[i] = 1000000001;
  }
  int length = 0;
  l[length] = a[0];
  length++;
  for (int i = (1); i < (n); i++) {
    if (l[length - 1] < a[i]) {
      l[length] = a[i];
      length++;
    } else {
      int j = length;
      while (1) {
        j--;
        if (l[j] > a[i]) {
          l[j] = a[i];
          break;
        }
      }
    }
  }
  cout << length << endl;
  return 0;
}
