N = int(eval(input()))

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



m = min(X)

M = max(X)



cost = [1000000009 for _ in range(101)]

for p in range(1,101):

    c = 0

    for x in X:

        c += (x-p)**2

    cost[p] = c



print((min(cost)))
N = int(eval(input()))

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



m = min(X)

M = max(X)



min_val = 100 * 100 * 100

for p in range(m, M+1):

    score = 0

    for x in X:

         score += (x-p)*(x-p)

    if score < min_val: min_val = score

print(min_val)

N = int(eval(input()))
X = list(map(int, input().split()))
m = min(X)
M = max(X)
cost = [1000000009 for _ in range(101)]
for p in range(1, 101):
    c = 0
    for x in X:
        c += (x - p) ** 2
    cost[p] = c
print((min(cost)))

N = int(eval(input()))
X = list(map(int, input().split()))
m = min(X)
M = max(X)
min_val = 100 * 100 * 100
for p in range(m, M + 1):
    score = 0
    for x in X:
        score += (x - p) * (x - p)
    if score < min_val:
        min_val = score
print(min_val)

-cost = [1000000009 for _ in range(101)] -for p in range(1, 101): -    c = 0 +min_val = 100 * 100 * 100 +for p in range(m, M + 1): +    score = 0 -        c += (x - p) ** 2 -    cost[p] = c -print((min(cost))) +        score += (x - p) * (x - p) +    if score < min_val: +        min_val = score +print(min_val)