#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T>>;
int main() {
  int n;
  stack<long long> S;
  cin >> n;
  int m = 0;
  S.push(-1);
  for (int(i) = (1); (i) < (n + 1); ++(i)) {
    long long a;
    cin >> a;
    if ((long long)S.top() < a) {
      S.push(a);
      m = max((int)S.size(), m);
    } else {
      while ((long long)S.top() >= a) {
        S.pop();
      }
      S.push(a);
      m = max((int)S.size(), m);
    }
  }
  cout << m - 1 << endl;
  ;
  return 0;
}
