program main
  implicit none
  integer :: n, me
  integer, allocatable :: x(:)
  read (*, *) n
  allocate (x(n))
  read (*, *) x(:)
  me = sum(x) / n
  write (*, "(i0)") min(sum((x(:) - me) ** 2), sum((x(:) - me - 1) ** 2))
  deallocate (x)
end program main
