#include <bits/stdc++.h>
using namespace std;
int ans[100000] = {0};
int main() {
  int n = 0;
  cin >> n;
  vector<pair<int, int> > v;
  v.push_back(pair<int, int>(INT_MAX, INT_MAX));
  int min = INT_MAX, max = 0;
  for (int i = 0; i < n; i++) {
    int input = 0;
    cin >> input;
    if (input == min) {
      ans[i] = 1;
      continue;
    }
    v.push_back(pair<int, int>(input, i));
    sort(v.begin(), v.end());
    if (input < min) {
      min = input;
      ans[i] = 1;
    } else {
      ans[i] = ans[v[lower_bound(v.begin(), v.end(),
                                 pair<int, int>(input, INT_MIN)) -
                     v.begin() - 1]
                       .second] +
               1;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] > max) {
      max = ans[i];
    }
  }
  cout << max << endl;
  return 0;
}
