eval(input())

x = sorted([int(i) for i in input().split()])

cost = sum([xi**2 for xi in x])

for p in range(x[0], x[-1] + 1):

    c = 0

    for xi in x:

        c += (xi - p)**2

    cost = min(c, cost)

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

x = [int(i) for i in input().split()]

p = round(sum(x) / n)

print((sum((i - p)**2 for i in x)))
eval(input())
x = sorted([int(i) for i in input().split()])
cost = sum([xi**2 for xi in x])
for p in range(x[0], x[-1] + 1):
    c = 0
    for xi in x:
        c += (xi - p) ** 2
    cost = min(c, cost)
print(cost)

n = int(eval(input()))
x = [int(i) for i in input().split()]
p = round(sum(x) / n)
print((sum((i - p) ** 2 for i in x)))

-eval(input()) -x = sorted([int(i) for i in input().split()]) -cost = sum([xi**2 for xi in x]) -for p in range(x[0], x[-1] + 1): -    c = 0 -    for xi in x: -        c += (xi - p) ** 2 -    cost = min(c, cost) -print(cost) +n = int(eval(input())) +x = [int(i) for i in input().split()] +p = round(sum(x) / n) +print((sum((i - p) ** 2 for i in x)))