n = int(eval(input()))

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

ans = 10 ** 9

for p in range(0, 101):

    cnt = 0

    for i in x:

        cnt += (i-p)**2

    ans = min(ans, cnt)

print(ans)
n = int(eval(input()))

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

ans1 = 0

ans2 = 0

xa = sum(x) // n

for i in x:

    ans1 += (abs(i-xa))**2



for i in x:

    ans2 += (abs(i-xa-1))**2



print((min(ans1, ans2)))

n = int(eval(input()))
x = list(map(int, input().split()))
ans = 10**9
for p in range(0, 101):
    cnt = 0
    for i in x:
        cnt += (i - p) ** 2
    ans = min(ans, cnt)
print(ans)

n = int(eval(input()))
x = list(map(int, input().split()))
ans1 = 0
ans2 = 0
xa = sum(x) // n
for i in x:
    ans1 += (abs(i - xa)) ** 2
for i in x:
    ans2 += (abs(i - xa - 1)) ** 2
print((min(ans1, ans2)))

-ans = 10**9 -for p in range(0, 101): -    cnt = 0 -    for i in x: -        cnt += (i - p) ** 2 -    ans = min(ans, cnt) -print(ans) +ans1 = 0 +ans2 = 0 +xa = sum(x) // n +for i in x: +    ans1 += (abs(i - xa)) ** 2 +for i in x: +    ans2 += (abs(i - xa - 1)) ** 2 +print((min(ans1, ans2)))