import statistics



am = int(eval(input()))

n_l = list(map(int, input().split(' ')))



m = round(statistics.mean(n_l))



S = 0

for a in range(am):

    S += (n_l[a] - m)**2



print((int(S)))
am = int(eval(input()))

n_l = list(map(int, input().split(' ')))



m = round(sum(n_l)/len(n_l))



S = 0

for a in range(am):

    S += (n_l[a] - m)**2



print((int(S)))
import statistics

am = int(eval(input()))
n_l = list(map(int, input().split(" ")))
m = round(statistics.mean(n_l))
S = 0
for a in range(am):
    S += (n_l[a] - m) ** 2
print((int(S)))

am = int(eval(input()))
n_l = list(map(int, input().split(" ")))
m = round(sum(n_l) / len(n_l))
S = 0
for a in range(am):
    S += (n_l[a] - m) ** 2
print((int(S)))

-import statistics - -m = round(statistics.mean(n_l)) +m = round(sum(n_l) / len(n_l))