Find the minimal possible perimeter of a convex $n$-gon with vertices at points with integer coordinates. The polygon must have interior angles less than $180$ degrees.
It is guaranteed that $n$ is even. For $n = 4$ the output should be $4$.
It is optimal do a square with side length $1$ in this test.
For $n = 10$ the output should be $14.12899$.
This is an example of a convex $10$-sided polygon with minimal perimeter (with vertices at integer coordinates). It has four sides of length $1$, four sides of length $\sqrt{2}$, and two sides of length $\sqrt{5}$, for a total of about $14.12899$. What is the formula?




Each edge corresponds to a point in $\mathbb Z^2\setminus\{0\}$. (To visualize this, pick an orientation, traverse the polygon and for each edge, shift the initial vertex to the origin and mark the final vertex with a dot.)
The contribution of an edge to the perimeter is the distance of the corresponding point in $\mathbb Z^2\setminus\{0\}$ from the origin. You can't use the same point twice (since that would produce an "angle of $\pi$" that the question disallows). So just add up the distances from the origin to the closest $n$ points in $\mathbb Z$.