n = int(eval(input()))

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



ans = 10000000

for p in range(1, max(X) + 1):

    total = 0

    for x in X:

        t = (x - p) ** 2

        total += t

    ans = min(total, ans)

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

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



ans = 10000000

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

    total = 0

    for x in X:

        t = (x - p) ** 2

        total += t

    ans = min(total, ans)

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

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

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