#include <iostream>
#include <cmath>
#include <algorithm>
struct coorrd {
int x, y, z;
}c[50005];
long long n;
bool sort(coorrd a, coorrd b) {
if (a.z < b.z)
return true;
else
return false;
}
double distance(coorrd a, coorrd b) {
double X = (a.x - b.x) * (a.x - b.x);
double Y = (a.y - b.y) * (a.y - b.y);
double Z = (a.z - b.z) * (a.z - b.z);
return sqrt(X + Y + Z);
}
int main() {
double ans = 0;
std::cin >> n;
for (int i = 1; i <= n; i++)
std::cin >> c[i].x >> c[i].y >> c[i].z;
std::sort(c + 1, c + 1 + n);
for (int i = 1; i < n; i++)
ans += distance(c[i], c[i + 1]);
printf("%3lf", ans);
return 0;
}