N = int(eval(input()))

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

L, R = min(X), max(X)



ans = 10**1000

for i in range(L, R+1):

    box = 0

    for j in range(N):

        box += (X[j] - i)**2

    if ans > box:

        ans = box



print(ans)

N = int(eval(input()))

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

P = round(sum(X)/N)

ans = 0

for i in range(N):

    ans += (X[i]-P)**2

print(ans)

N = int(eval(input()))
X = [int(i) for i in input().split()]
L, R = min(X), max(X)
ans = 10**1000
for i in range(L, R + 1):
    box = 0
    for j in range(N):
        box += (X[j] - i) ** 2
    if ans > box:
        ans = box
print(ans)

N = int(eval(input()))
X = [int(i) for i in input().split()]
P = round(sum(X) / N)
ans = 0
for i in range(N):
    ans += (X[i] - P) ** 2
print(ans)

-L, R = min(X), max(X) -ans = 10**1000 -for i in range(L, R + 1): -    box = 0 -    for j in range(N): -        box += (X[j] - i) ** 2 -    if ans > box: -        ans = box +P = round(sum(X) / N) +ans = 0 +for i in range(N): +    ans += (X[i] - P) ** 2