eolymp
bolt
Try our new interface for solving problems
Problems

Underground Cables

Underground Cables

Time limit 1 second
Memory limit 128 MiB

A city wants to get rid of their unsightly power poles by moving their power cables underground. They have a list of points that all need to be connected, but they have some limitations. Their tunneling equipment can only move in straight lines between points. They only have room for one underground cable at any location except at the given points, so no two cables can cross.

Given a list of points, what is the least amount of cable necessary to make sure that every pair of points is connected, either directly, or indirectly through other points?

Input data

There are several test cases. Each test case starts with an integer n~(2 \le n \le 1000), which is the number of points in the city. On each of the next n lines will be two integers x and y~(-1000 \le x, y \le 1000), which are the (x, y) locations of the n points. Within a test case, all points will be distinct. The input will end with a line with a single 0.

Output data

For each test case output a single real number, representing the least amount of cable the city will need to connect all of its points. Print this number with exactly two decimal places, rounded. Print each number on its own line with no spaces. Do not print any blank lines between answers.

Examples

Input example #1
4
0 0
0 10
10 0
10 10
2
0 0
10 10
0
Output example #1
30.00
14.14
Source 2010 ACM North America, Mid-Atlantic, Problem H