import math

N = int(eval(input()))

X = list(map(int,input().split()))

medf = math.floor(sum(X)/N)

medc = math.ceil(sum(X)/N)

cf = 0

cc = 0

for i in range(N):

  cf += (X[i] - medf)**2

  cc += (X[i] - medc)**2

print((min(cf,cc)))
import math

N = int(eval(input()))

X = list(map(int,input().split()))

med = int(sum(X)/N + 0.5)

c = 0

for i in range(N):

  c += (X[i] - med)**2

print(c)

import math

N = int(eval(input()))
X = list(map(int, input().split()))
medf = math.floor(sum(X) / N)
medc = math.ceil(sum(X) / N)
cf = 0
cc = 0
for i in range(N):
    cf += (X[i] - medf) ** 2
    cc += (X[i] - medc) ** 2
print((min(cf, cc)))

import math

N = int(eval(input()))
X = list(map(int, input().split()))
med = int(sum(X) / N + 0.5)
c = 0
for i in range(N):
    c += (X[i] - med) ** 2
print(c)

-medf = math.floor(sum(X) / N) -medc = math.ceil(sum(X) / N) -cf = 0 -cc = 0 +med = int(sum(X) / N + 0.5) +c = 0 -    cf += (X[i] - medf) ** 2 -    cc += (X[i] - medc) ** 2 -print((min(cf, cc))) +    c += (X[i] - med) ** 2 +print(c)