n = int(eval(input()))

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



cost = [0] * 201

for i in range(201):

    for j in a:

        cost[i] += ((i - 100) - j) ** 2



print((min(cost)))
n = int(eval(input()))

A = [int(i) for i in input().split()]

ave = round(sum(A) / n)

ans = 0

for x in A:

    ans += (x-ave)**2

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
cost = [0] * 201
for i in range(201):
    for j in a:
        cost[i] += ((i - 100) - j) ** 2
print((min(cost)))

n = int(eval(input()))
A = [int(i) for i in input().split()]
ave = round(sum(A) / n)
ans = 0
for x in A:
    ans += (x - ave) ** 2
print(ans)

-a = list(map(int, input().split())) -cost = [0] * 201 -for i in range(201): -    for j in a: -        cost[i] += ((i - 100) - j) ** 2 -print((min(cost))) +A = [int(i) for i in input().split()] +ave = round(sum(A) / n) +ans = 0 +for x in A: +    ans += (x - ave) ** 2 +print(ans)