public boolean canJump(int[] A) {
        // wirte your code here
        int n=A.length;
        int mr=0;
        for (int i=0;;) {
            int pmr=mr;
            for (;i<n&&i<=mr;++i) {
                mr=Math.max(A[i]+i,mr);
            }
            if (mr>=n-1)
                return true;
            if (pmr==mr)
                return false;
        }
    }