#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int MX = 100000;
  vector<vector<int>> dp(N + 1, vector<int>(100000));
  for (int n = 0; n < (int)(N); ++n) {
    int a;
    cin >> a;
    if (n == 0) {
      dp[n + 1][a] = 1;
    } else {
      for (int b = 0; b < (int)(a); ++b) {
        dp[n + 1][a] = max(max(dp[n][a], dp[n + 1][a]), dp[n][b] + 1);
      }
      for (int b = 0; b < (int)(MX + 1); ++b) {
        dp[n + 1][b] = max(dp[n][b], dp[n + 1][b]);
      }
    }
  }
  int ret = 0;
  for (int b = 0; b < (int)(MX + 1); ++b) {
    ret = max(ret, dp[N][b]);
  }
  cout << ret << endl;
  return 0;
}
