n = int(eval(input()))

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





ans = 10**9

for p in range(1,101):

    a = 0

    for k in x:

        a+=(k-p)**2

    ans = min(ans,a)



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

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



s = round(sum(x)/n)

ans = [(a-s)**2 for a in x]



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

n = int(eval(input()))
x = list(map(int, input().split()))
s = round(sum(x) / n)
ans = [(a - s) ** 2 for a in x]
print((sum(ans)))

-ans = 10**9 -for p in range(1, 101): -    a = 0 -    for k in x: -        a += (k - p) ** 2 -    ans = min(ans, a) -print(ans) +s = round(sum(x) / n) +ans = [(a - s) ** 2 for a in x] +print((sum(ans)))