program ABC156C
    implicit none
    integer(8)::N,i,j,hp_min,hp
    integer(8),allocatable,dimension(:)::X
    read(5,*)N
    allocate(X(N))
    read(5,*)(X(i),i=1,N)

    hp_min=1000000000
    do i=minval(X),maxval(X)
        hp=0
        do j=1,N
            hp=hp+(X(j)-i)**2
        end do
        hp_min=min(hp_min,hp)
    end do

    print'(i0)',hp_min
end program ABC156C