#include <bits/stdc++.h>
const int oo = 2 * int(1e9);
const int maxn = int(1e5) + 11;
FILE *f, *f1;
int hd[maxn], next[maxn], pre[maxn], dau[maxn], a[maxn];
int i, n, l = 0, r = 0, u, v;
int main() {
  f = stdin;
  f1 = stdout;
  fscanf(f, "%d ", &n);
  for (i = 1; i <= n; i++)
    fscanf(f, "%d ", &a[i]), next[i] = i + 1, pre[i] = i - 1;
  a[0] = -oo;
  a[n + 1] = oo;
  for (i = 1; i < n; i++)
    if (a[i] > a[i + 1]) hd[++r] = i + 1, dau[i + 1] = 1;
  while (l < r) {
    u = hd[++l];
    next[pre[u]] = next[u];
    pre[next[u]] = pre[u];
    v = next[u];
    if ((a[pre[v]] > a[v]) && (dau[v] == 0)) hd[++r] = v, dau[v] = dau[u] + 1;
  }
  fprintf(f1, "%d", dau[hd[r]]);
  fclose(f);
  fclose(f1);
}
