#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N];
  int L[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  L[0] = A[0];
  int length = 0;
  for (int i = 1; i < N; ++i) {
    if (L[length] < A[i])
      L[++length] = A[i];
    else if (A[i] < L[0])
      L[0] = A[i];
    else {
      int s = length / 4, k = length / 2;
      while (1) {
        if (A[i] > L[k + 1] && L[k] < A[i]) {
          L[k + 1] = A[i];
          break;
        }
        if (A[i] < L[k])
          k -= s;
        else
          k += s;
        if (s <= 1)
          break;
        else
          s /= 2;
      }
    }
  }
  cout << length + 1 << endl;
}
