#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
int sez[100005];
int rec(int le, int de) {
  int r = 0;
  int glob = 1;
  stack<int> A;
  A.push(sez[de]);
  for (int i = de - 1; i >= le; i--) {
    while (!A.empty() && A.top() < sez[i]) {
      glob--;
      A.pop();
    }
    A.push(sez[i]);
    glob++;
    r = max(r, glob);
  }
  return r;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> sez[i];
  int prev = 0;
  int rez = 0;
  for (int i = 1; i < n; i++) {
    if (sez[i] > sez[prev]) {
      rez = max(rez, rec(prev, i - 1));
      prev = i;
    }
  }
  rez = max(rez, rec(prev, n - 1));
  cout << rez;
  return 0;
}
