#include <bits/stdc++.h>
using namespace std;
int main() {
  queue<int> q;
  int n;
  cin >> n;
  int ans = 0;
  int a[n];
  int next[n];
  int d[n];
  memset(d, 0, sizeof(d));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    next[i] = i + 1;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] > a[i + 1]) {
      q.push(i);
      d[i] = 1;
      ans = 1;
      next[i] = next[next[i]];
    }
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (next[x] != n && a[x] > a[next[x]]) {
      d[x] = d[x] + 1;
      next[x] = next[next[x]];
      ans = max(ans, d[x]);
      q.push(x);
    }
  }
  printf("%d\n", ans);
  return 0;
}
