#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAXN = 1e5 + 10;
int v[MAXN];
int lis[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int a = 0; a < n; ++a) scanf("%d", &v[a]);
  memset(lis, INF, sizeof(lis));
  for (int a = 0; a < n; ++a) {
    int i = lower_bound(lis, lis + n, v[a]) - lis;
    lis[i] = v[a];
  }
  int hi = 0;
  for (int a = 0; a < n; ++a)
    if (lis[a] != INF) hi = a;
  printf("%d\n", hi + 1);
  return 0;
}
