import numpy as np

M=int(eval(input()))

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

x=int(round(np.mean(n)))

ans=0

for i in n:

    ans=ans+(i-x)**2

print(ans)

M=int(eval(input()))

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

x=int(round(sum(n)/M))

ans=0

for i in n:

    ans=ans+(i-x)**2

print(ans)

import numpy as np

M = int(eval(input()))
n = list(map(int, input().split()))
x = int(round(np.mean(n)))
ans = 0
for i in n:
    ans = ans + (i - x) ** 2
print(ans)

M = int(eval(input()))
n = list(map(int, input().split()))
x = int(round(sum(n) / M))
ans = 0
for i in n:
    ans = ans + (i - x) ** 2
print(ans)

-import numpy as np - -x = int(round(np.mean(n))) +x = int(round(sum(n) / M))