#include <bits/stdc++.h>
using namespace std;
int dp[100001];
int res = 0;
int n;
int a[100000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i] = 10000000009;
  }
  int res = 1;
  for (int j = 0; j < n; j++) {
    for (int i = 0; i <= j; i++) {
      if (i == 0 || dp[i - 1] < a[j]) {
        dp[i] = min(dp[i], a[j]);
        res = max(res, i + 1);
      }
    }
  }
  cout << res << endl;
  return 0;
}
