#include <bits/stdc++.h>
using namespace std;
struct data {
  int pos, step;
  data() {}
  data(int a, int b) { pos = a, step = b; }
};
queue<data> Q;
int nxt[100000 + 10], val[100000 + 10];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> val[i];
    nxt[i] = i + 1;
  }
  for (int i = n - 1; i >= 1; i--) {
    if (val[i] > val[i + 1]) Q.push(data(i, 1));
  }
  int ans = 0;
  while (!Q.empty()) {
    data get = Q.front();
    Q.pop();
    ans = max(ans, get.step);
    nxt[get.pos] = nxt[nxt[get.pos]];
    if (nxt[get.pos] != n + 1 && val[get.pos] > val[nxt[get.pos]])
      Q.push(data(get.pos, get.step + 1));
  }
  cout << ans << endl;
  return 0;
}
