#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 L[n];
  L[0] = A[0];
  int length = 1;
  for (int i = 1; i < n; ++i) {
    if (A[i] > L[length - 1]) {
      L[length++] = A[i];
    } else {
      int left = 0;
      int right = length;
      while (left < right) {
        int mid = (left + right) / 2;
        if (A[mid] > A[i]) {
          right = mid;
        } else {
          left = mid + 1;
        }
      }
      L[right] = A[i];
    }
  }
  cout << length << endl;
  return 0;
}
