import java.util.Scanner;
public class To10 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int arr[][] = new int[n][3];
for(int i=0; i<n; i++){
arr[i][0] = scan.nextInt();
arr[i][1] = scan.nextInt();
arr[i][2] = scan.nextInt();
}
//每個村到0號的花費
double a[][] = new double [n][2];
for(int i =1;i<n;i++){
a[i][0] = Math.sqrt(((arr[0][0]-arr[i][0])*(arr[0][0]-arr[i][0])+
(arr[0][1]-arr[i][1])*(arr[0][1]-arr[i][1])))
+ (arr[0][2]-arr[i][2])*(arr[0][2]-arr[i][2]);
a[i][1] = i;
}
//對花費進(jìn)行排序
for(int i =1;i<n-1;i++){
for(int j=i+1;j<n-1;j++){
if(a[i][0]>a[j][0]){
double b=a[i][0];
a[i][0]=a[j][0];
a[j][0]=b;
double c=a[i][1];
a[i][1]=a[j][1];
a[j][1]= c;
}
}
}
double hei[] = new double[n];
hei[1] = a[1][0];
double sum = hei[1];
for(int i =2;i<n-1;i++){
hei[i] = a[i][0];
for(int j=i-1;j>=1;j--){
int e = (int) a[i][1];
int? f= (int) a[j][1];
hei[i] = hei[i]<(Math.sqrt(((arr[e][0]-arr[f][0])*(arr[e][0]-arr[f][0])+
(arr[e][1]-arr[f][1])*(arr[e][1]-arr[f][1])))
+ (arr[e][2]-arr[f][2])*(arr[e][2]-arr[f][2]))?hei[i]:(Math.sqrt(((arr[e][0]-arr[f][0])*(arr[e][0]-arr[f][0])+
(arr[e][1]-arr[f][1])*(arr[e][1]-arr[f][1])))
+ (arr[e][2]-arr[f][2])*(arr[e][2]-arr[f][2]));
}
sum+=hei[i];
}
? ? ? int v= (int) (sum*100);
System.out.println((double)v/100);
}
}