#include <bits/stdc++.h>
using namespace std;
int n, ans, a[100005], nxt[100005], m[100005];
queue<pair<int, int> > q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    nxt[i - 1] = i;
    q.push(make_pair(i, 1));
  }
  while (!q.empty()) {
    pair<int, int> x = q.front();
    q.pop();
    if (m[x.first]) continue;
    int tut = x.first;
    while (nxt[tut] && a[nxt[tut]] < a[tut]) {
      m[nxt[tut]] = 1;
      tut = nxt[tut];
      ans = max(ans, x.second);
    }
    nxt[x.first] = nxt[tut];
    if (x.first != tut) {
      x.second++;
      q.push(x);
    }
  }
  printf("%d", ans);
}
