Computing the minimum distance between each pain of points
Suppose the points are $[4,1,10,11]$.  The distance from the starting point (whether you interpret that as $4$ or $1$) to each other point does not give you the nearest pair of points.

In this problem, the input is an array containing numbers, not in sorted order.