import math

from statistics import mean, median,variance,stdev

N = int(eval(input()))

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

a = sum(X)

ave = round(a/N)

b = 0

for i in range(N):

    b +=(X[i]-ave)**2

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

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

ans = 10**8

c = int()

for i in range(1,100):

    c = 0

    for j in range(len(X)):

        c += (X[j]-i)**2

    if c < ans:

        ans = c

print(ans)
import math
from statistics import mean, median, variance, stdev

N = int(eval(input()))
X = list(map(int, input().split()))
a = sum(X)
ave = round(a / N)
b = 0
for i in range(N):
    b += (X[i] - ave) ** 2
print(b)

N = int(eval(input()))
X = list(map(int, input().split()))
ans = 10**8
c = int()
for i in range(1, 100):
    c = 0
    for j in range(len(X)):
        c += (X[j] - i) ** 2
    if c < ans:
        ans = c
print(ans)

-import math -from statistics import mean, median, variance, stdev - -a = sum(X) -ave = round(a / N) -b = 0 -for i in range(N): -    b += (X[i] - ave) ** 2 -print(b) +ans = 10**8 +c = int() +for i in range(1, 100): +    c = 0 +    for j in range(len(X)): +        c += (X[j] - i) ** 2 +    if c < ans: +        ans = c +print(ans)