eolymp
Problems

Waterpipe - 2

Waterpipe - 2

prb86In the plan area is depicted N cottages, which have known coordinates X, Y (i = 1 .. N). What is the minimum length should be the total length of water pipes that connects all the houses N of the town, directly or through several intermediate houses?

Input

The first line number N - the number of houses. The next N lines coordinates cottages X, Y (i = 1 .. N). All input values are natural numbers not greater than 100.

Output

Single number - the total length of water pipes, rounded to integers.

Time limit 1 second
Memory limit 64 MiB
Input example #1
7
3 4
4 3
1 3
3 5
2 3
2 2
1 1
Output example #1
7