program abc156c
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans
    integer(int32), allocatable:: x(:)

    read*, n
    allocate(x(n))
    read*, x(:)

    ans = 1000000000
    do i=minval(x),maxval(x)
        ans = min(ans,sum((x(:)-i)**2))
    end do
    print'(i0)', ans
end program abc156c