public static int findPeak(int[] A) {
        // write your code here
        int l=0, r=A.length;
        while (true) {
            int m=l+(r-l)/2;
            if (A[m-1]<A[m]&&A[m+1]<A[m])
                return m;
            else if (A[m-1]>A[m])
                r=m-1;
            else 
                l=m+1;
        }
    }