#include <bits/stdc++.h>
using namespace std;
int N;
int A[100000], dp[100000];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    dp[i] = 1;
  }
  for (int i = N - 2; i >= 0; i--)
    for (int j = i; j < N; j++) dp[i] = max(dp[i], dp[j] + (A[i] < A[j]));
  printf("%d\n", dp[0]);
}
