#include <bits/stdc++.h>
using namespace std;
static const long long inf = 1ll << 60;
static const long long MAX_N = 1e+5;
long long N;
long long a[MAX_N];
long long mem[MAX_N];
long long cal(long long n) {
  long long res = 0;
  if (mem[n] != -1) return mem[n];
  if (n == N - 1) return 0;
  for (long long i = n + 1; i < N; ++i) {
    if (a[n] >= a[i]) continue;
    res = max(cal(i) + 1, res);
  }
  return mem[n] = res;
}
long long ans = 0;
signed main() {
  cout << setprecision(16);
  memset(mem, -1, sizeof(mem));
  cin >> N;
  for (long long i = 0; i < N; ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i <= N; ++i) {
    ans = max(cal(i) + 1, ans);
  }
  cout << ans << endl;
}
