#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
int n, ans, ar[100005], reyiz[100005], fl[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i]);
    reyiz[i] = i + 1;
    q.push(make_pair(i, 1));
  }
  while (!q.empty()) {
    pair<int, int> t = q.front();
    q.pop();
    int ind = t.first;
    int step = t.second;
    if (fl[ind]) continue;
    while (reyiz[ind] != n + 1 && ar[ind] > ar[reyiz[ind]]) {
      fl[reyiz[ind]] = 1;
      ind = reyiz[ind];
      ans = max(ans, step);
    }
    reyiz[t.first] = reyiz[ind];
    if (ind != t.first) {
      t.second++;
      q.push(t);
    }
  }
  printf("%d\n", ans);
}
