n = int(eval(input()))

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

ans = float('inf')

for i in range(101):

    now = 0

    for j in range(n):

        now += (x[j] - i) ** 2

    ans = min(ans, now)

print(ans)

n = int(eval(input()))

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

avg = sum(x) / n

if avg % 1 >= 0.5:

    avg += 1

avg = int(avg)

ans = 0

for xi in x:

    ans += (xi - avg) ** 2

print(ans)
n = int(eval(input()))
x = list(map(int, input().split()))
ans = float("inf")
for i in range(101):
    now = 0
    for j in range(n):
        now += (x[j] - i) ** 2
    ans = min(ans, now)
print(ans)

n = int(eval(input()))
x = list(map(int, input().split()))
avg = sum(x) / n
if avg % 1 >= 0.5:
    avg += 1
avg = int(avg)
ans = 0
for xi in x:
    ans += (xi - avg) ** 2
print(ans)

-ans = float("inf") -for i in range(101): -    now = 0 -    for j in range(n): -        now += (x[j] - i) ** 2 -    ans = min(ans, now) +avg = sum(x) / n +if avg % 1 >= 0.5: +    avg += 1 +avg = int(avg) +ans = 0 +for xi in x: +    ans += (xi - avg) ** 2