N = int(eval(input()))

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

X = list(sorted(X))

if N == 1:

  print((0))

  exit()

ans = float('inf')

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

  sum = 0

  for x in X:

    sum += (x - p) ** 2

  ans = min(sum, ans)

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

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

avg = round(sum(X) / N)

print((sum([(x - avg) ** 2 for x in X])))
N = int(eval(input()))
X = list(map(int, input().split()))
X = list(sorted(X))
if N == 1:
    print((0))
    exit()
ans = float("inf")
for p in range(X[0], X[N - 1] + 1):
    sum = 0
    for x in X:
        sum += (x - p) ** 2
    ans = min(sum, ans)
print(ans)

N = int(eval(input()))
X = list(map(int, input().split()))
avg = round(sum(X) / N)
print((sum([(x - avg) ** 2 for x in X])))

-X = list(sorted(X)) -if N == 1: -    print((0)) -    exit() -ans = float("inf") -for p in range(X[0], X[N - 1] + 1): -    sum = 0 -    for x in X: -        sum += (x - p) ** 2 -    ans = min(sum, ans) -print(ans) +avg = round(sum(X) / N) +print((sum([(x - avg) ** 2 for x in X])))