#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[1000000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int dp[1000000] = {};
  for (int t = 1; t < 100001; t++) {
    for (int i = 1; i < n; i++) {
      if (a[i] != t) {
        continue;
      }
      for (int h = 0; h < i; h++) {
        if (a[i] > a[h]) {
          dp[i] = max(dp[i], dp[i - h] + 1);
        }
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}
