#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, w;
  int a[100010];
  int dp[100010];
  cin >> n;
  for (int i = 0; i < n + 1; i++) dp[i] = 1999999999;
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[1] = a[0];
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j >= 1; j--) {
      if (j == 1)
        dp[j] = min(dp[j], a[i]);
      else if (dp[j - 1] < a[i])
        dp[j] = min(dp[j], a[i]);
    }
  }
  int ans = n;
  while (dp[n] == 1999999999) n--;
  cout << n << endl;
  return 0;
}
