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