#include <bits/stdc++.h>
using namespace std;
long long int a[100000], buf[100000];
int n, dp[100001], ans;
struct stl_sort_functor_cmp {
  bool operator()(const long long int& a, const long long int& b) const {
    return b > a;
  }
};
int main() {
  scanf("%d", &n);
  for (int i = 0; n > i; i++) scanf("%lld", &a[i]);
  for (int i = 0; n > i; i++) {
    memcpy(buf, a, sizeof(long long int) * (i + 1));
    sort(buf, buf + (i + 1), stl_sort_functor_cmp());
    for (int j = 0; i > j; j++) {
      if (buf[j] >= a[i]) break;
      if (dp[j] == ans) {
        dp[i] = ans + 1;
        break;
      }
      dp[i] = (((dp[i]) > (dp[j] + 1)) ? (dp[i]) : (dp[j] + 1));
    }
    if (!dp[i]) dp[i] = 1;
    ans = (((ans) > (dp[i])) ? (ans) : (dp[i]));
  }
  printf("%d\n", ans);
}
