#include<bits/stdc++.h>
using namespace std;
int a[10000],b[10000],c[10000],n;
double sum;
double remote(int x1,int y1,int z1,int x2,int y2,int z2)
{
double ans=0;
ans=sqrt(pow(x1-x2,2)+pow(y1-y2,2)+pow(z1-z2,2));
return ans;
}
inline void write(int x)
{
if(x>9)write(x/10);
putchar(x%10^48);
}
inline int read()
{
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void quicksort(int c[],int l,int r)
{
int mid=c[(l+r)/2];
int i=l,j=r;
do
{
while(c[i]<mid) i++;
while(c[j]>mid) j--;
if(i<=j)
{
swap(c[i],c[j]);
swap(a[i],a[j]);
swap(b[i],b[j]);
i++;
j--;
}
}
while(i<=j);
if(l<j) quicksort(c,l,j);
if(i<r) quicksort(c,i,r);
}
int main()
{
n=read();
for(int i=0;i<n;i++)
{
a[i]=read();
b[i]=read();
c[i]=read();
}
quicksort(c,0,n-1);
for(int i=0;i<n-1;i++)
{
sum+=remote(a[i],b[i],c[i],a[i+1],b[i+1],c[i+1]);
}
cout<<setiosflags(ios::fixed)<<setprecision(3)<<sum;
return 0;
}