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