import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines class Point: def __init__(self, x, y, z): self.x=x self.y=y self.z=z def __add__(self, other): return Point(self.x+other.x, self.y+other.y, self.z+other.z) def __sub__(self, other): return Point(self.x-other.x, self.y-other.y, self.z-other.z) def __mul__(self, other): return Point(self.x*other, self.y*other, self.z*other) def dot(self, other): return self.x*other.x+self.y*other.y+self.z*other.z n=int(readline()) px, py, pz=map(float, readline().split()) p=Point(px, py, pz) xyzs=list(map(float, read().split())) xs=xyzs[::3] ys=xyzs[1::3] zs=xyzs[2::3] qs=[Point(x, y, z) for x, y, z in zip(xs, ys, zs)] import itertools, math ans=0 for q1, q2, q3 in itertools.combinations(qs, 3): a, b, c=q1-p, q2-q1, q3-q1 ab, ac, bb, bc, cc=a.dot(b), a.dot(c), b.dot(b), b.dot(c), c.dot(c) d=bb*cc-bc*bc s=(-cc*ab+bc*ac)/d t=(bc*ab-bb*ac)/d e=a+b*s+c*t ans+=math.sqrt(e.dot(e)) print('{:.10f}'.format(ans))