#include <bits/stdc++.h>
using namespace std;
const double EPS = 10e-6;
vector<int> a;
map<pair<short, short>, short> memo;
int dp(short now, short p) {
  if (now == a.size()) return 0;
  if (memo.count(pair<short, short>(now, p)))
    return memo[pair<short, short>(now, p)];
  int ans = 0;
  if (a[now] > a[p]) {
    ans = max(dp(now + 1, now) + 1, dp(now + 1, p));
  } else
    ans = dp(now + 1, p);
  return memo[pair<short, short>(now, p)] = ans;
}
int main() {
  int n;
  cin >> n;
  a.push_back(-1);
  for (int i = 0; i < (int)n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  cout << dp(0, 0) << endl;
}
