import numpy as np



n = int(eval(input()))

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

x2 = np.power(x,2)



p1 = sum(x)//n

p2 = -(-sum(x)//n)



w1 = n*(p1**2) -2*sum(x)*p1 +sum(x2)

w2 = n*(p2**2) -2*sum(x)*p2 +sum(x2)



print((min(w1,w2)))
n = int(eval(input()))

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

ans = 10**6



for i in range(X[0],X[-1]+1):

    HP = 0

    

    for j in X:

        HP += (j - i) ** 2

        

    ans = min(ans,HP)

    

print(ans)
import numpy as np

n = int(eval(input()))
x = list(map(int, input().split()))
x2 = np.power(x, 2)
p1 = sum(x) // n
p2 = -(-sum(x) // n)
w1 = n * (p1**2) - 2 * sum(x) * p1 + sum(x2)
w2 = n * (p2**2) - 2 * sum(x) * p2 + sum(x2)
print((min(w1, w2)))

n = int(eval(input()))
X = sorted(map(int, input().split()))
ans = 10**6
for i in range(X[0], X[-1] + 1):
    HP = 0
    for j in X:
        HP += (j - i) ** 2
    ans = min(ans, HP)
print(ans)

-import numpy as np - -x = list(map(int, input().split())) -x2 = np.power(x, 2) -p1 = sum(x) // n -p2 = -(-sum(x) // n) -w1 = n * (p1**2) - 2 * sum(x) * p1 + sum(x2) -w2 = n * (p2**2) - 2 * sum(x) * p2 + sum(x2) -print((min(w1, w2))) +X = sorted(map(int, input().split())) +ans = 10**6 +for i in range(X[0], X[-1] + 1): +    HP = 0 +    for j in X: +        HP += (j - i) ** 2 +    ans = min(ans, HP) +print(ans)