N = int(eval(input()))

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



res = float('inf')



for i in range(-100, 101):

    tmp = 0

    for x in X:

        tmp += (i - x) ** 2



    res = min(tmp, res)



print(res)
N = int(eval(input()))

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



res = float('inf')



for i in range(min(X), max(X)+1):

    tmp = 0

    for x in X:

        tmp += (i - x) ** 2



    res = min(tmp, res)



print(res)
N = int(eval(input()))
X = list(map(int, input().split()))
res = float("inf")
for i in range(-100, 101):
    tmp = 0
    for x in X:
        tmp += (i - x) ** 2
    res = min(tmp, res)
print(res)

N = int(eval(input()))
X = list(map(int, input().split()))
res = float("inf")
for i in range(min(X), max(X) + 1):
    tmp = 0
    for x in X:
        tmp += (i - x) ** 2
    res = min(tmp, res)
print(res)

-for i in range(-100, 101): +for i in range(min(X), max(X) + 1):