program kadai
integer  ::  N
integer,allocatable  ::  X(:)
integer  ::  i
integer  ::  a
integer  ::  ans1,ans2

read(*,*) N
allocate(X(N))
read(*,*) X

a=0
ans1=0
ans2=0
do i=1,N
    a=a+x(i)
end do


a=a/N
do i=1,N
    ans1=ans1+(x(i)-a)**2
    ans2=ans2+(x(i)-(a+1))**2
end do

write(*,*) min(ans1,ans2)
stop



end program kadai
