Shortest Path among co-ordinates

Given (N+1) points. All the N points lie on x- axis. Remaining one point (HEAD point) lies anywhere in the coordinate plane. Given a START point on x- axis.

Find the shortest distance to cover all the points starting from START point.We can traverse a point multiple times.

Example -


points on x axis

HEAD Point
(1,1) // only head point can lie anywhere ,rest all will lie on x axis


Shortest path -

(1,0) → (2,0) → (1,1) → (0,0)
Length of path → 1 + 1.414 + 1.414.

Pls help me with the logic / code