Fix exception thrown when closestToCenterIndex was 0.