n=int(eval(input()))

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

ave=round(sum(a)/n)

a=[(x-ave)**2 for x in a]

print((sum(a)))

n=int(eval(input()))

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

avg=round(sum(a)/n)

ans=0

for i in range(n):

    ans+=(a[i]-avg)**2

print(ans)



n = int(eval(input()))
a = list(map(int, input().split()))
ave = round(sum(a) / n)
a = [(x - ave) ** 2 for x in a]
print((sum(a)))

n = int(eval(input()))
a = list(map(int, input().split()))
avg = round(sum(a) / n)
ans = 0
for i in range(n):
    ans += (a[i] - avg) ** 2
print(ans)

-ave = round(sum(a) / n) -a = [(x - ave) ** 2 for x in a] -print((sum(a))) +avg = round(sum(a) / n) +ans = 0 +for i in range(n): +    ans += (a[i] - avg) ** 2 +print(ans)