import sys

readline = sys.stdin.readline

N = int(readline())

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

X.sort()



INF = 10**9+7

ans = INF

for p in range(0, 102):

    res = 0

    for x in X:

        res += (p-x)**2

    ans = min(ans, res)

print(ans)

n = int(eval(input()))

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

a = round(sum(x) / n)

print((sum(((i - a) ** 2) for i in x)))
import sys

readline = sys.stdin.readline
N = int(readline())
X = list(map(int, readline().split()))
X.sort()
INF = 10**9 + 7
ans = INF
for p in range(0, 102):
    res = 0
    for x in X:
        res += (p - x) ** 2
    ans = min(ans, res)
print(ans)

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

-import sys - -readline = sys.stdin.readline -N = int(readline()) -X = list(map(int, readline().split())) -X.sort() -INF = 10**9 + 7 -ans = INF -for p in range(0, 102): -    res = 0 -    for x in X: -        res += (p - x) ** 2 -    ans = min(ans, res) -print(ans) +n = int(eval(input())) +(*x,) = list(map(int, input().split())) +a = round(sum(x) / n) +print((sum(((i - a) ** 2) for i in x)))