N = int(eval(input()))

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

sav = float("inf")

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

    Xe = [abs(x-i)**2 for x in X]

    health = sum(Xe)

    if sav > health:

        sav = health



print(sav)

N = int(eval(input()))

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

xp = round(sum(X) / N)

Xe = [abs(x - xp) ** 2 for x in X]

print((sum(Xe)))

N = int(eval(input()))
X = list(map(int, input().split()))
sav = float("inf")
for i in range(min(X), max(X) + 1):
    Xe = [abs(x - i) ** 2 for x in X]
    health = sum(Xe)
    if sav > health:
        sav = health
print(sav)

N = int(eval(input()))
X = list(map(int, input().split()))
xp = round(sum(X) / N)
Xe = [abs(x - xp) ** 2 for x in X]
print((sum(Xe)))

-sav = float("inf") -for i in range(min(X), max(X) + 1): -    Xe = [abs(x - i) ** 2 for x in X] -    health = sum(Xe) -    if sav > health: -        sav = health -print(sav) +xp = round(sum(X) / N) +Xe = [abs(x - xp) ** 2 for x in X] +print((sum(Xe)))