N = int(eval(input()))

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

ans = 10**9+7

for i in range(1, 101):

    p = 0

    for x in Xlist:

        p += (x-i)**2

    ans = min(ans, p)

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

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

ans = 10**9

for p in range(min(Xlist), max(Xlist)+1):

    cost = 0

    for x in Xlist:

        cost += (x - p)**2

    ans = min(ans, cost)

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

N = int(eval(input()))
Xlist = list(map(int, input().split()))
ans = 10**9
for p in range(min(Xlist), max(Xlist) + 1):
    cost = 0
    for x in Xlist:
        cost += (x - p) ** 2
    ans = min(ans, cost)
print(ans)

-ans = 10**9 + 7 -for i in range(1, 101): -    p = 0 +ans = 10**9 +for p in range(min(Xlist), max(Xlist) + 1): +    cost = 0 -        p += (x - i) ** 2 -    ans = min(ans, p) +        cost += (x - p) ** 2 +    ans = min(ans, cost)