#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
template <typename T>
int SIZE(T(&t)) {
  return t.size();
}
template <typename T, size_t N>
int SIZE(T (&t)[N]) {
  return N;
}
string to_string(char t) { return "'" + string({t}) + "'"; }
string to_string(bool t) { return t ? "true" : "false"; }
string to_string(const string &t, int x1 = 0, int x2 = 1e9) {
  string ret = "";
  for (int i = min(x1, SIZE(t)), _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
    ret += t[i];
  }
  return '"' + ret + '"';
}
string to_string(const char *t) {
  string ret(t);
  return to_string(ret);
}
template <size_t N>
string to_string(const bitset<N> &t, int x1 = 0, int x2 = 1e9) {
  string ret = "";
  for (int i = min(x1, SIZE(t)); i <= min(x2, SIZE(t) - 1); ++i) {
    ret += t[i] + '0';
  }
  return to_string(ret);
}
template <typename T, typename... Coords>
string to_string(const T(&t), int x1 = 0, int x2 = 1e9, Coords... C);
template <typename T, typename S>
string to_string(const pair<T, S> &t) {
  return "(" + to_string(t.first) + ", " + to_string(t.second) + ")";
}
template <typename T, typename... Coords>
string to_string(const T(&t), int x1, int x2, Coords... C) {
  string ret = "[";
  x1 = min(x1, SIZE(t));
  auto e = begin(t);
  advance(e, x1);
  for (int i = x1, _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
    ret += to_string(*e, C...) + (i != _i ? ", " : "");
    e = next(e);
  }
  return ret + "]";
}
template <int Index, typename... Ts>
struct print_tuple {
  string operator()(const tuple<Ts...> &t) {
    string ret = print_tuple<Index - 1, Ts...>{}(t);
    ret += (Index ? ", " : "");
    return ret + to_string(get<Index>(t));
  }
};
template <typename... Ts>
struct print_tuple<0, Ts...> {
  string operator()(const tuple<Ts...> &t) { return to_string(get<0>(t)); }
};
template <typename... Ts>
string to_string(const tuple<Ts...> &t) {
  const auto Size = tuple_size<tuple<Ts...>>::value;
  return print_tuple<Size - 1, Ts...>{}(t);
}
void dbgr() { ; }
template <typename Heads, typename... Tails>
void dbgr(Heads H, Tails... T) {
  cout << to_string(H) << " | ";
  dbgr(T...);
}
void dbgs() { ; }
template <typename Heads, typename... Tails>
void dbgs(Heads H, Tails... T) {
  cout << H << " ";
  dbgs(T...);
}
const int MOD = 1000000007;
template <typename T_vector>
void output_vector(const T_vector &v, bool line_break = false,
                   bool add_one = false, int start = -1, int end = -1) {
  if (start < 0) start = 0;
  if (end < 0) end = int(v.size());
  for (int i = start; i < end; i++) {
    cout << v[i] + (add_one ? 1 : 0)
         << (line_break    ? '\n'
             : i < end - 1 ? ' '
                           : '\n');
  }
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> candidates;
  set<int> alive;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> a[i];
    alive.insert(i);
    candidates.push_back(i);
  }
  for (int ans = 0;; ans++) {
    vector<int> killers, dead;
    for (auto &(cur_candidate) : (candidates)) {
      auto it = alive.find(cur_candidate);
      if (it == alive.end()) continue;
      auto next_candidate = next(it);
      if (next_candidate == alive.end()) continue;
      if (a[cur_candidate] > a[*next_candidate]) {
        killers.push_back(cur_candidate);
        dead.push_back(*next_candidate);
      }
    }
    if (SIZE(killers) == 0) {
      cout << ans << '\n';
      return;
    }
    for (auto &(x) : (dead)) alive.erase(x);
    candidates = killers;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step. 

You're given the initial arrangement of the psychos in the line. Calculate how many steps are needed to the moment of time such, that nobody kills his neighbor after that moment. Look notes to understand the statement more precise.

Input

The first line of input contains integer n denoting the number of psychos, (1 ≤ n ≤ 105). In the second line there will be a list of n space separated distinct integers each in range 1 to n, inclusive — ids of the psychos in the line from left to right.

Output

Print the number of steps, so that the line remains the same afterward.

Examples

Input

10
10 9 7 8 6 5 3 4 2 1


Output

2


Input

6
1 2 3 4 5 6


Output

0

Note

In the first sample line of the psychos transforms as follows: [10 9 7 8 6 5 3 4 2 1]  →  [10 8 4] →  [10]. So, there are two steps.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
template <typename T>
int SIZE(T(&t)) {
  return t.size();
}
template <typename T, size_t N>
int SIZE(T (&t)[N]) {
  return N;
}
string to_string(char t) { return "'" + string({t}) + "'"; }
string to_string(bool t) { return t ? "true" : "false"; }
string to_string(const string &t, int x1 = 0, int x2 = 1e9) {
  string ret = "";
  for (int i = min(x1, SIZE(t)), _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
    ret += t[i];
  }
  return '"' + ret + '"';
}
string to_string(const char *t) {
  string ret(t);
  return to_string(ret);
}
template <size_t N>
string to_string(const bitset<N> &t, int x1 = 0, int x2 = 1e9) {
  string ret = "";
  for (int i = min(x1, SIZE(t)); i <= min(x2, SIZE(t) - 1); ++i) {
    ret += t[i] + '0';
  }
  return to_string(ret);
}
template <typename T, typename... Coords>
string to_string(const T(&t), int x1 = 0, int x2 = 1e9, Coords... C);
template <typename T, typename S>
string to_string(const pair<T, S> &t) {
  return "(" + to_string(t.first) + ", " + to_string(t.second) + ")";
}
template <typename T, typename... Coords>
string to_string(const T(&t), int x1, int x2, Coords... C) {
  string ret = "[";
  x1 = min(x1, SIZE(t));
  auto e = begin(t);
  advance(e, x1);
  for (int i = x1, _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
    ret += to_string(*e, C...) + (i != _i ? ", " : "");
    e = next(e);
  }
  return ret + "]";
}
template <int Index, typename... Ts>
struct print_tuple {
  string operator()(const tuple<Ts...> &t) {
    string ret = print_tuple<Index - 1, Ts...>{}(t);
    ret += (Index ? ", " : "");
    return ret + to_string(get<Index>(t));
  }
};
template <typename... Ts>
struct print_tuple<0, Ts...> {
  string operator()(const tuple<Ts...> &t) { return to_string(get<0>(t)); }
};
template <typename... Ts>
string to_string(const tuple<Ts...> &t) {
  const auto Size = tuple_size<tuple<Ts...>>::value;
  return print_tuple<Size - 1, Ts...>{}(t);
}
void dbgr() { ; }
template <typename Heads, typename... Tails>
void dbgr(Heads H, Tails... T) {
  cout << to_string(H) << " | ";
  dbgr(T...);
}
void dbgs() { ; }
template <typename Heads, typename... Tails>
void dbgs(Heads H, Tails... T) {
  cout << H << " ";
  dbgs(T...);
}
const int MOD = 1000000007;
template <typename T_vector>
void output_vector(const T_vector &v, bool line_break = false,
                   bool add_one = false, int start = -1, int end = -1) {
  if (start < 0) start = 0;
  if (end < 0) end = int(v.size());
  for (int i = start; i < end; i++) {
    cout << v[i] + (add_one ? 1 : 0)
         << (line_break    ? '\n'
             : i < end - 1 ? ' '
                           : '\n');
  }
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> candidates;
  set<int> alive;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> a[i];
    alive.insert(i);
    candidates.push_back(i);
  }
  for (int ans = 0;; ans++) {
    vector<int> killers, dead;
    for (auto &(cur_candidate) : (candidates)) {
      auto it = alive.find(cur_candidate);
      if (it == alive.end()) continue;
      auto next_candidate = next(it);
      if (next_candidate == alive.end()) continue;
      if (a[cur_candidate] > a[*next_candidate]) {
        killers.push_back(cur_candidate);
        dead.push_back(*next_candidate);
      }
    }
    if (SIZE(killers) == 0) {
      cout << ans << '\n';
      return;
    }
    for (auto &(x) : (dead)) alive.erase(x);
    candidates = killers;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

```