#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a) {
  for (auto i : a) cout << i << endl;
}
vector<int> a;
int memo[100000];
int dp(int now) {
  if (now >= a.size()) return 0;
  if (memo[now] != -1) return memo[now];
  int ans = 1;
  for (int i = now + 1; i < (int)a.size(); i++)
    ans = max(ans, dp(i) + (a[now] < a[i]));
  return memo[now] = ans;
}
int main() {
  int n;
  cin >> n;
  ;
  memset(memo, -1, sizeof memo);
  for (int i = 0; i < (int)n; i++) {
    int x;
    cin >> x;
    ;
    a.push_back(x);
  }
  cout << dp(0) << endl;
}
