local ior = io.input() local n = ior:read("*n") local px, py, pz = ior:read("*n", "*n", "*n") local tx, ty, tz = {}, {}, {} for i = 1, n do tx[i], ty[i], tz[i] = ior:read("*n", "*n", "*n") end local function getlen(idxs) local x, y, z = {}, {}, {} for i = 1, 3 do x[i], y[i], z[i] = tx[idxs[i]], ty[idxs[i]], tz[idxs[i]] end x[4], y[4], z[4] = px, py, pz for i = 2, 4 do x[i], y[i], z[i] = x[i] - x[1], y[i] - y[1], z[i] - z[1] end local e1sz = math.sqrt(x[2] * x[2] + y[2] * y[2] + z[2] * z[2]) local e1 = {x[2] / e1sz, y[2] / e1sz, z[2] / e1sz} local innerpr = e1[1] * x[3] + e1[2] * y[3] + e1[3] * z[3] local e2 = { x[3] - innerpr * e1[1], y[3] - innerpr * e1[2], z[3] - innerpr * e1[3] } local e2sz = math.sqrt(e2[1] * e2[1] + e2[2] * e2[2] + e2[3] * e2[3]) for i = 1, 3 do e2[i] = e2[i] / e2sz end local e3 = {x[4], y[4], z[4]} innerpr = e3[1] * e1[1] + e3[2] * e1[2] + e3[3] * e1[3] for i = 1, 3 do e3[i] = e3[i] - e1[i] * innerpr end innerpr = e3[1] * e2[1] + e3[2] * e2[2] + e3[3] * e2[3] for i = 1, 3 do e3[i] = e3[i] - e2[i] * innerpr end local e3sz = math.sqrt(e3[1] * e3[1] + e3[2] * e3[2] + e3[3] * e3[3]) for i = 1, 3 do e3[i] = e3[i] / e3sz end innerpr = e3[1] * x[4] + e3[2] * y[4] + e3[3] * z[4] return innerpr end local sum = 0 for i = 1, n - 2 do for j = i + 1, n - 1 do for k = j + 1, n do sum = sum + getlen({i, j, k}) end end end print(string.format("%.10f", sum))