#include <iostream>
#include <cmath>
using namespace std;
const int MAXN = 100;
enum Ifexist {R, U}; // Remain-set and U-set
// U集合表示最终为MST节点的集合
// Remain集合表示当前还剩元素
struct Point {
double x, y;
Ifexist ife;
};
Point r[MAXN];//REMAIN
bool isempty(int n, Point s[]);// 谓词:判断Remain集合是否为空
inline double calculateD(Point a, Point b);
int main() {
double x, y;
int n;
int keepi;
double kmin, ans;
while (cin >> n) {
ans = 0;
for (int i = 0; i < n; ++i) {
cin >> x >> y;
r[i].x = x;
r[i].y = y;
r[i].ife = R;
}
r[0].ife = U;
while (!isempty(n, r)) {
kmin = 100000;
// On^2 计算R和U 集合最近元素距离
for (int i = 0; i < n; ++i) {
if (r[i].ife == R) {
for (int j = 0; j < n; ++j) {
if (r[j].ife == U) {
double dst = calculateD(r[i], r[j]);
if (dst < kmin) {
kmin = dst;
keepi = i;
}
}
}
}
}
ans += kmin;// 累加R和U集合最近的边
r[keepi].ife = U;//R节点数目减一,也意味着U集合加一
}
cout.precision(2);
//cout<<ans<<endl;
printf("%.2f\n", ans);
}
return 0;
}
bool isempty(int n, Point s[]) {
for (int i = 0; i < n; ++i) {
if (s[i].ife == R)
return false;
}
return true;
}
inline double calculateD(Point a, Point b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}