# Arup Guha
# 4/3/2026
# Solution to COP 4516 Problem: Underground Cables

import heapq

def prims(edgeList):

    n = len(edgeList)

    # vertices connected in our tree.
    used = [False]*n
    used[0] = True
    done = 1
    res = 0

    # Set up heap of edges.
    myheap = []
    for x in edgeList[0]:
        heapq.heappush(myheap, x)

    while done != n and len(myheap) > 0:

        curE = heapq.heappop(myheap)

        # Doesn't go anywhere new.
        if used[curE[1]] and used[curE[2]]:
            continue

        newV = -1
        if not used[curE[1]]:
            used[curE[1]] = True
            newV = curE[1]
        else:
            used[curE[2]] = True
            newV = curE[2]

        # Add to mst cost.
        res += curE[0]
        done += 1

        # Add all edges.
        for x in edgeList[newV]:
            heapq.heappush(myheap, x)

    if done < n:
        return -1
    return res

    
def main():

    # Process cases.
    n = int(input())
    while n != 0:

        # Get points.
        pts = []
        for i in range(n):
            tmp = [int(x) for x in input().split()]
            pts.append(tmp)

        # Create edge list, edges from each vertex.
        edgeList = []
        for i in range(n):

            myList = []
            for j in range(n):
                dx = pts[i][0] - pts[j][0]
                dy = pts[i][1] - pts[j][1]
                d = (dx*dx+dy*dy)**.5
                myList.append([d,i,j])
            edgeList.append(myList)

        # Run it and output results.
        mst = prims(edgeList)
        print(f"{mst:.2f}")

        # Get next.
        n = int(input())

main()
