#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100009];
  cin >> n;
  int M[100009];
  for (int i = 0; i < n; i++) cin >> a[i];
  int L = 0;
  for (int i = 0; i < n; i++) {
    int lo = 1, hi = L;
    while (lo <= hi) {
      int mid = lo + hi;
      mid = mid / 2 + mid % 2;
      if (a[M[mid]] < a[i])
        lo = mid + 1;
      else
        hi = mid - 1;
    }
    int newL = lo;
    M[newL] = i;
    L = max(newL, L);
  }
  cout << L << "\n";
  return 0;
}
