integer N
integer,allocatable,dimension(:)::a
integer ans,kouho
read*,N
allocate(a(N))
read*,a
ans=huge(ans)
do i=minval(a),maxval(a)
  kouho=0
  do j=1,N
    kouho=kouho+(i-a(j))**2
  end do
  ans=max(ans,kouho)
end do
print"(i0)",ans
end