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