def calc(s,t):

       return (t-s)**2



n=int(eval(input()))

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

inf=float("inf")



ans=inf

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

       u=0

       for j in X:

              u+=calc(i,j)

       ans=min(ans,u)

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

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



s=float("inf")

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

   d=0

   for j in X:

      d+=(j-i)**2

   s=min(s,d)

print(s)

   
def calc(s, t):
    return (t - s) ** 2


n = int(eval(input()))
X = sorted(list(map(int, input().split())))
inf = float("inf")
ans = inf
for i in range(X[0], X[-1] + 1):
    u = 0
    for j in X:
        u += calc(i, j)
    ans = min(ans, u)
print(ans)

n = int(eval(input()))
X = list(map(int, input().split()))
s = float("inf")
for i in range(min(X), max(X) + 1):
    d = 0
    for j in X:
        d += (j - i) ** 2
    s = min(s, d)
print(s)

-def calc(s, t): -    return (t - s) ** 2 - - -X = sorted(list(map(int, input().split()))) -inf = float("inf") -ans = inf -for i in range(X[0], X[-1] + 1): -    u = 0 +X = list(map(int, input().split())) +s = float("inf") +for i in range(min(X), max(X) + 1): +    d = 0 -        u += calc(i, j) -    ans = min(ans, u) -print(ans) +        d += (j - i) ** 2 +    s = min(s, d) +print(s)