#include"iostream"
#include"algorithm"
#include"cmath"
using namespace std;
const int N = 1024;
struct point
{
int x, y, z;
}a[N];
bool cmp(point a, point b)
{
return a.z < b.z;
}
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i].x >> a[i].y >> a[i].z;
}
sort(a, a + n, cmp);
double path=0;
for (int i = 0; i < n-1; i++)
{
path += sqrt(pow((a[i+1].x - a[i].x), 2) + pow(a[i+1].y - a[i].y, 2) + pow(a[i+1].z - a[i].z, 2));
}
printf("%.3lf", path);
return 0;
}