Scanf.scanf "%d" (fun n ->
    let xy = Array.init n (fun _ -> Scanf.scanf " %f %f" (fun x y -> x, y)) in

    let dist a b =
        let x1, y1 = xy.(a) in
        let x2, y2 = xy.(b) in
        sqrt ((x1 -. x2) *. (x1 -. x2) +. (y1 -. y2) *. (y1 -. y2))
    in

    let rec loop1 i1 acc =
        let rec loop2 i2 acc =
            if i2 = n then acc else
                loop2 (i2 + 1) (acc +. dist i1 i2)
        in
        if i1 = n then acc else
            loop1 (i1 + 1) (loop2 (i1 + 1) acc)
    in
    let s = loop1 0 0. *. 2. /. float n in
    Printf.printf "%.8f\n" s
)