#include <bits/stdc++.h>   using namespace std;   const int MAXN = 111111;   const int oo = (int)(1e9);   int MOD = 1000000007;   const long double PI = 3.141592653589793;   template <typename TT>   void read(TT &x) {     char ch;     for (ch = getchar(); ch >  9  || ch <  0 ; ch = getchar())       ;     for (x = 0; ch >=  0  && ch <=  9 ; ch = getchar()) x = x * 10 + ch - 48;   }   vector<pair<int, int> > A[2];   int n, a[111111], v[111111], nt[111111];   void work(vector<pair<int, int> > &B, vector<pair<int, int> > &C) {     C.clear();     sort(B.begin(), B.end());     for (int i = B.size() - 1; i >= 0; i--) {       int x = B[i].first, y = B[i].second;       if (v[x] + v[y] > 0) continue;       v[y] = 1;       while (v[nt[x]]) nt[x] = nt[nt[x]];       if (nt[x] < n && a[x] > a[nt[x]]) C.push_back(make_pair(x, nt[x]));     }   }   void Init() {     scanf( %d , &n);     ;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     ;     for (int i = 0; i < n; i++) {       nt[i] = i + 1;       if (nt[i] < n && a[i] > a[nt[i]]) A[0].push_back(make_pair(i, nt[i]));     }     int k = 0, ans = 0;     memset(v, 0, sizeof(v));     ;     while (A[k].size()) {       ans++;       work(A[k], A[1 - k]);       k = 1 - k;     }     printf( %d , ans);     ;   }   int main() {     Init();     return 0;   }   