Waterpipe - 2#86

Waterpipe - 2

1 second
64 megabytes
Medium

A city plan shows cottages, located at coordinates (X_i, Y_i) for i = 1, \ldots, N. What is the minimum total length of water pipes required to connect all cottages, either directly or via other cottages?

Input

The first line contains a single integer (1 \leq N \leq 100) — the number of cottages. Each of the next lines contains two positive integers X_i and Y_i (1 \leq X_i, Y_i \leq 100), representing the coordinates of a cottage.

Output

Print a single integer — the minimum total length of water pipes required to connect all cottages, rounded to the nearest integer.

Examples

Example 1

Loading
Loading