#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010, INF = ~0U >> 2;
int n, A[MAXN], D[MAXN], res;
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
}
void solve() {
  D[0] = -INF;
  int l, r, mid, x;
  res = 0;
  for (int i = 0; i < n; i++) {
    x = A[i];
    if (x > D[res])
      D[++res] = x;
    else {
      l = 0;
      r = res;
      while (l < r) {
        mid = l + r + 1 >> 1;
        if (x > D[mid])
          l = mid;
        else
          r = mid - 1;
      }
      D[l + 1] = x;
    }
  }
}
void pri() { printf("%d\n", res); }
int main() {
  init();
  solve();
  pri();
  return 0;
}
