n = int(eval(input()))

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

ans = 1000000000

for p in range(1,100):

    s = 0

    for x in X:

        s += (x-p)**2

    ans = min(ans, s)

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

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

ans = 1000000000

for p in range(1,101):

    s = 0

    for x in X:

        s += (x-p)**2

    ans = min(ans, s)

print(ans)
n = int(eval(input()))
X = list(map(int, input().split()))
ans = 1000000000
for p in range(1, 100):
    s = 0
    for x in X:
        s += (x - p) ** 2
    ans = min(ans, s)
print(ans)

n = int(eval(input()))
X = list(map(int, input().split()))
ans = 1000000000
for p in range(1, 101):
    s = 0
    for x in X:
        s += (x - p) ** 2
    ans = min(ans, s)
print(ans)

-for p in range(1, 100): +for p in range(1, 101):