First compare the first and last elements in a range of indices in A.