program main
  implicit none
  integer :: N
  integer,allocatable :: X(:)
  integer :: mdist
  integer :: dist
  integer :: i,j
  read(*,*) N
  allocate( X(N) )
  read(*,*) X(:)
  mdist = 100**2*N
  do i = 1,maxval(X)
     dist = 0
     do j = 1, N
        dist = dist + (X(j)-i)**2
     end do
     if ( mdist > dist ) then
        mdist = dist
     end if
  end do
  write(*,'(i0)') mdist
  deallocate( X )
end program main
