program sample
    implicit none
  
    integer(8) :: i,j,k,m,n,x,y
    real(8)::b
    integer(8),allocatable :: a(:)
  
    read(*,*) n
    allocate(a(n))
    k=sum(a)/n
    m=k+1
    x=0
    y=0
    do i=1,n
        x=x+(a(i)-k)**2
        y=y+(a(i)-m)**2
        
    end do
    if (x>=y)then
        write(*,*) y
    
    else
        write(*,*) x
    end if
  
    stop
end program sample
  

