#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
class height {
public:
height(double x, double y, double z) {
this->x = x;
this->y = y;
this->z = z;
}
double x, y, z;
};
bool mysort(height h1, height h2) {
return h1.y < h2.y;
}
int main() {
double n, x, y, z;
double s = 0;
vector<height>cont;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x >> y >> z;
height h(x, y, z);
cont.push_back(h);
}
sort(cont.begin(), cont.end(), mysort);
double x1, y1, z1;
height* itt = &cont[0];
for (vector<height>::iterator it = ++cont.begin(); it != cont.end(); it++,itt++) {
x1 = pow(it->x - itt->x, 2);
y1 = pow(it->y - itt->y, 2);
z1 = pow(it->z - itt->z, 2);
s += pow(x1 + y1 + z1, 0.5);
}
printf("%.3lf", s);
}