#include <bits/stdc++.h>
using namespace std;
int n;
double ans;
struct mate{
int x,y,z;
}a[50100];
bool cmp(mate x,mate y){
return x.z < y.z;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i].x >> a[i].y >> a[i].z;
}
sort(a + 1,a + n + 1,cmp);
for(int i = 1;i < n;i++){
int q = (a[i].x - a[i + 1].x);
int b = (a[i].x - a[i + 1].x);
int c = (a[i].y - a[i + 1].y);
int d = (a[i].y - a[i + 1].y);
int e = (a[i].z - a[i + 1].z);
int f = (a[i].z - a[i + 1].z);
int w = sqrt(q + b + c + d + e + f);
ans += q;
}
cout << ans << fixed << setprecision(3);
return 0;
}