N = int(eval(input()))

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

cmin = 10**6

for i in range(101):

    cnt = 0

    for x in X:

        cnt += (x-i)**2

    cmin = min(cmin,cnt)

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

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

cmin = 10**6

for i in range(1,101):

    cnt = 0

    for j in range(N):

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

    cmin = min(cmin,cnt)

print(cmin)
N = int(eval(input()))
X = list(map(int, input().split()))
cmin = 10**6
for i in range(101):
    cnt = 0
    for x in X:
        cnt += (x - i) ** 2
    cmin = min(cmin, cnt)
print(cmin)

N = int(eval(input()))
X = list(map(int, input().split()))
cmin = 10**6
for i in range(1, 101):
    cnt = 0
    for j in range(N):
        cnt += (i - X[j]) ** 2
    cmin = min(cmin, cnt)
print(cmin)

-for i in range(101): +for i in range(1, 101): -    for x in X: -        cnt += (x - i) ** 2 +    for j in range(N): +        cnt += (i - X[j]) ** 2