#include <bits/stdc++.h>
using namespace std;
static const int N = 100001;
int n;
int A[N], L[N], P[N];
int lis() {
  L[0] = 0;
  A[0] = 0;
  P[0] = -1;
  int i, j, k;
  for (i = 1; i <= n; i++) {
    k = 0;
    for (j = 0; j < i; j++) {
      if (A[j] < A[i] && L[j] > L[k]) k = j;
      L[i] = L[k] + 1;
      P[i] = k;
    }
  }
  return L[n];
}
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> A[i];
  }
  cout << lis() << endl;
  return 0;
}
