#include <bits/stdc++.h>
using namespace std;
int a[100004], L[100004], I[100004];
int LIS(int a[], int n) {
  I[0] = -2000000000;
  for (int i = 1; i <= n; i++) I[i] = 2000000000;
  int len = 0;
  for (int i = 0; i < n; i++) {
    int low, high, mid;
    low = 0, high = len;
    while (low <= high) {
      mid = (low + high) / 2;
      if (I[mid] < a[i])
        low = mid + 1;
      else
        high = mid - 1;
    }
    I[low] = a[i];
    if (len < low) len = low;
  }
  return len;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << LIS(a, n) << endl;
  return 0;
}
