#include <bits/stdc++.h>
using namespace std;
int n;
struct location
{
int x;
int y;
int z;
}lt[50001];
bool cmp(location& lt1,location& lt2)
{
return lt1.z<lt2.z;
}
int main()
{
cin >> n;
for(int i=0;i<n;i++)
{
cin>>lt[i].x>>lt[i].y>>lt[i].z;
}
sort(lt,lt+n-1,cmp);
double ans=0;
for(int i=0;i<n-1;i++)
{
ans+=sqrt(pow(lt[i].x-lt[i+1].x,2)+pow(lt[i].y-lt[i+1].y,2)+pow(lt[i].z-lt[i+1].z,2));
}
printf("%.3f",ans);
return 0;
}