n=int(eval(input()))



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



res = 100000000000000000000000000000000



t.sort()

#print(t)

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

    memo = 0

    for j in t:

        memo += (j-i)**2

    res = min(memo, res)



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



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



ans = 10000000000000000



for i in range(101):

    tmp = 0

    for x in X:

        tmp += (i-x)**2

    ans = min(ans, tmp)

print(ans)
n = int(eval(input()))
t = list(map(int, input().split()))
res = 100000000000000000000000000000000
t.sort()
# print(t)
for i in range(t[0], t[-1] + 1):
    memo = 0
    for j in t:
        memo += (j - i) ** 2
    res = min(memo, res)
print(res)

N = int(eval(input()))
X = list(map(int, input().split()))
ans = 10000000000000000
for i in range(101):
    tmp = 0
    for x in X:
        tmp += (i - x) ** 2
    ans = min(ans, tmp)
print(ans)

-n = int(eval(input())) -t = list(map(int, input().split())) -res = 100000000000000000000000000000000 -t.sort() -# print(t) -for i in range(t[0], t[-1] + 1): -    memo = 0 -    for j in t: -        memo += (j - i) ** 2 -    res = min(memo, res) -print(res) +N = int(eval(input())) +X = list(map(int, input().split())) +ans = 10000000000000000 +for i in range(101): +    tmp = 0 +    for x in X: +        tmp += (i - x) ** 2 +    ans = min(ans, tmp) +print(ans)