min distance in sorted array