#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int A[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }
  int V[n];
  V[0] = A[0];
  int length = 1;
  for (int i = 1; i <= n; ++i) {
    if (A[i] > V[length - 1]) {
      V[length++] = A[i];
    } else {
      int l = 0;
      int r = length;
      while (l < r) {
        int mid = (l + r) / 2;
        if (A[i] < V[mid]) {
          r = mid;
        } else {
          l = mid + 1;
        }
      }
      V[r] = A[i];
    }
  }
  cout << length << endl;
  return 0;
}
