#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 50005;
int N;
double sum;
struct point{
int x, y, z;
bool operator <(const point &other)const{
return z < other.z;
}
}mp[MAXN];
double EuclidDis(point a, point b){
return sqrt((a.y - b.y) * (a.y - b.y) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z));
}
bool pointSort(point a, point b){
return a.z > b.z;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N;
for(int i = 1; i <= N; i++) cin >> mp[i].x >> mp[i].y >> mp[i].z;
sort(mp + 1, mp + 1 + N);
for(int i = 2; i <= N; i++) sum += EuclidDis(mp[i], mp[i - 1]);
cout << fixed << setprecision(3) << sum << '\n';
return 0;
}