program average_length
    implicit none
    integer(4):: n, dn
    integer(4),allocatable:: p(:,:)
    integer(4):: i,j,k
    real(8), allocatable:: d(:)

    read*, n
    dn = n*(n-1)/2
    allocate(p(2,n))
    allocate(d(dn))
    do i=1, n
        read*, p(:,i)
    end do

    block; integer(4):: c=1, x1, y1
    do i=1,n-1
        x1 = p(1,i)
        y1 = p(2,i) 
        do j=i+1,n
            d(c) = sqrt(dble(((x1-p(1,j))*(x1-p(1,j))) + (y1-p(2,j))*(y1-p(2,j))))
            c=c+1
        end do
    end do
    end block

    print*, sum(d(:))*2/dble(n)
end program average_length