N=int(eval(input()))

X=[int(s) for s in input().split()]



sum=0

Ans=0

count=0

Xmax=sorted(X)[N-1]

Xmax2=sorted(X)[N-2]



for i in range(2*Xmax):

    sum=0

    for j in range(N):

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

    count+=1

    if count==1:

        Ans=sum

    Ans=min(Ans,sum)

    



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

X=[int(s) for s in input().split(" ")]



X.sort()



Ans=N*(X[-1]**2)

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

    Sum=0

    for j in range(N):

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

    if Sum<Ans:

        Ans=Sum



print(Ans)
N = int(eval(input()))
X = [int(s) for s in input().split()]
sum = 0
Ans = 0
count = 0
Xmax = sorted(X)[N - 1]
Xmax2 = sorted(X)[N - 2]
for i in range(2 * Xmax):
    sum = 0
    for j in range(N):
        sum += (X[j] - i) ** 2
    count += 1
    if count == 1:
        Ans = sum
    Ans = min(Ans, sum)
print(Ans)

N = int(eval(input()))
X = [int(s) for s in input().split(" ")]
X.sort()
Ans = N * (X[-1] ** 2)
for i in range(X[-1] + 1):
    Sum = 0
    for j in range(N):
        Sum = Sum + (X[j] - i) ** 2
    if Sum < Ans:
        Ans = Sum
print(Ans)

-X = [int(s) for s in input().split()] -sum = 0 -Ans = 0 -count = 0 -Xmax = sorted(X)[N - 1] -Xmax2 = sorted(X)[N - 2] -for i in range(2 * Xmax): -    sum = 0 +X = [int(s) for s in input().split(" ")] +X.sort() +Ans = N * (X[-1] ** 2) +for i in range(X[-1] + 1): +    Sum = 0 -        sum += (X[j] - i) ** 2 -    count += 1 -    if count == 1: -        Ans = sum -    Ans = min(Ans, sum) +        Sum = Sum + (X[j] - i) ** 2 +    if Sum < Ans: +        Ans = Sum