N = int(eval(input()))

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

al = []

for i in range(100):

  d = 0

  p = i+1

  for j in range(N):

    d += (X[j]-p)**2

  al.append(d)



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

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

X = sorted(X)

avg = sum(X)//N

aa = []

for i in range(2):

  avg = avg + i

  a = 0

  for j in range(N):

    a += (X[j] - avg)**2

  aa.append(a)

print((min(aa)))
N = int(eval(input()))
X = list(map(int, input().split()))
al = []
for i in range(100):
    d = 0
    p = i + 1
    for j in range(N):
        d += (X[j] - p) ** 2
    al.append(d)
print((min(al)))

N = int(eval(input()))
X = list(map(int, input().split()))
X = sorted(X)
avg = sum(X) // N
aa = []
for i in range(2):
    avg = avg + i
    a = 0
    for j in range(N):
        a += (X[j] - avg) ** 2
    aa.append(a)
print((min(aa)))

-al = [] -for i in range(100): -    d = 0 -    p = i + 1 +X = sorted(X) +avg = sum(X) // N +aa = [] +for i in range(2): +    avg = avg + i +    a = 0 -        d += (X[j] - p) ** 2 -    al.append(d) -print((min(al))) +        a += (X[j] - avg) ** 2 +    aa.append(a) +print((min(aa)))