#include <bits/stdc++.h>
using namespace std;
int N;
int A[100000];
int lis(void) {
  int L[N + 1];
  int ans = 0;
  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[k] < L[j]) k = j;
    }
    L[i] = L[k] + 1;
    ans = max(ans, L[i]);
  }
  return ans;
}
int main(void) {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  A[0] = 0;
  cout << lis() << endl;
  return 0;
}
