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.
import static java.lang.System.*;
import static java.lang.Math.*;


import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class D320{
    public static Scanner sc = new Scanner(in);
    //public static Random sc=new Random();

    static class Node{
        int id,h,turn=0;
        List<Node> link=new LinkedList<Node>();
        Node(int _id,int _h){
            id=_id;h=_h;
        }
    }

    public void run(){
        int n=sc.nextInt();


        Node[] nodes=new Node[n];

        for(int i=0;i<n;i++){
            nodes[i]=new Node(i,sc.nextInt());
        }

        List<Node> que=new ArrayList<>();

        loop:for(int i=0;i<n;i++){

            for(int j=que.size()-1;j>=0;j--){
                Node node=que.get(j);
                if(node.h>nodes[i].h){
                    node.link.add(nodes[i]);
                    node.turn=max(nodes[i].turn+1,node.turn+1);
                    for(int k=j+1;k<que.size();k++)que.remove(j+1);
                    que.add(nodes[i]);
                    continue loop;
                }else{
                    que.remove(j);
                }
            }
            que.add(nodes[i]);
        }

        int M=0;

        for(int i=0;i<n;i++){
            M=max(nodes[i].turn,M);
        }

        ln(M);
    }

    public static void main(String[] _) {
        new D320().run();
    }
    //output lib
    static final String br=System.getProperty("line.separator");
    static final String[] asep=new String[]{""," ",br,br+br};
    static String str(Boolean o){
        return o?"YES":"NO";
    }
//  static String str(Double o){
//      return String.format("%.8f",o);
//  }
    static <K,V> String str(Map<K, V> map){
        StringBuilder sb=new StringBuilder();
        boolean isFirst=true;
        for(Entry<K,V> set:map.entrySet()){
            if(!isFirst)sb.append(br);
            sb.append(str(set.getKey())).append(":").append(str(set.getValue()));
            isFirst=false;
        }
        return sb.toString();
    }
    static <E> String str(Collection<E> list){
        StringBuilder sb=new StringBuilder();
        boolean isFirst=true;
        for(E e:list){
            if(!isFirst)sb.append(" ");
            sb.append(str(e));
            isFirst=false;
        }
        return sb.toString();
    }

    static String str(Object o){
        int depth=_getArrayDepth(o);
        if(depth>0)return _strArray(o,depth);
        Class<?> c=o.getClass();
        if(c.equals(Boolean.class))return str((Boolean)o);
        //if(c.equals(Double.class))return str((Double)o);

        return o.toString();
    }
    static int _getArrayDepth(Object o){
        if(!o.getClass().isArray() || Array.getLength(o)==0) return 0;
        return  1+_getArrayDepth(Array.get(o,0));
    }
    static String _strArray(Object o,int depth){
        if(depth==0) return str(o);
        StringBuilder sb=new StringBuilder();
        for(int i=0,len=Array.getLength(o);i<len;i++){
            if(i!=0)sb.append(asep[depth]);
            sb.append(_strArray(Array.get(o,i),depth-1));
        }
        return sb.toString();
    }
    static void pr(Object... os){
        boolean isFirst=true;
        for(Object o:os){
            if(!isFirst)out.print(" ");
            out.print(o);
            isFirst=false;
        }
    }
    static void ln(){
        out.println();
    }
    static void ln(Object... os){
        for(Object o:os){
            pr(o);ln();
        }
    }
}