program abc043c
  implicit none
  integer :: n, i, t, ans = 10000000
  integer,allocatable :: a(:)
  read *, n
  allocate(a(n))
  read *, a
  do i = -100,100
     t = sum(abs(a-i)**2)
     if (t < ans) ans = t;
  end do
  print *, ans
end program abc043c
