#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 100000;
int A[MAX_N + 1];
int L[MAX_N + 1];
int P[MAX_N + 1];
int n;
int lis() {
  L[0] = 0;
  A[0] = 0;
  P[0] = -1;
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    int k = 0;
    for (int j = 0; j < i; ++j) {
      if (A[j] < A[i] && L[j] > L[k]) k = j;
    }
    L[i] = L[k] + 1;
    P[i] = k;
    res = max(res, L[i]);
  }
  return res;
}
int main(int argc, char** argv) {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &A[i]);
  printf("%d\n", lis());
  return 0;
}
