#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int A[n + 1];
  for (int i = 1; i <= n; ++i) {
    int v;
    scanf("%d", &v);
    A[i] = v;
  }
  int L[n + 1];
  int P[n - 1];
  L[0] = 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;
  }
  int maxv = 0;
  for (int i = 1; i <= n; ++i) {
    maxv = max(L[i], maxv);
  }
  cout << maxv << endl;
  return 0;
}
