program rally
  implicit none
  integer :: n, x(100) = 0, i, p
  read(*,*) n
  read(*,*) x(1:n)
  p = sum(x(1:n))/n
  write(*,'(i0)') min(sum((x(1:n)-p)*(x(1:n)-p)),sum((x(1:n)-p-1)*(x(1:n)-p-1)))
end program rally