module C
  sub Main(byval args() as string)
    dim n as integer = integer.parse(console.readline())
    dim arr() as string = split(console.readline())
    dim x() as integer = array.convertall(of string,integer)(arr,addressof integer.parse)
    array.sort(x)
    dim i,a,y,z as integer
    z=0
    for a=x(0) to x(n-1)
    	y=0
        for i=0 to n-1
          	y+=(x(i)-a)^2
        next
  		if a=x(0) then
    		z=y
  		else
    		if z>y then z=y
  		end if
    next
    console.writeline(z)
  end sub
end module