i<j && A[i]<=A[j], get largest distance