n = int(eval(input()))

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



ans = 10**18

for i in range(0,101):

    curr_sum = 0

    for x in xl:

        curr_sum += (i-x)*(i-x)

    ans = min(ans,curr_sum)



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

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

ans = 10**9



for i in range(1,101):

    v = 0

    for x in xl:

        v += (x-i)**2

    ans = min(ans,v)



print(ans)
n = int(eval(input()))
xl = list(map(int, input().split()))
ans = 10**18
for i in range(0, 101):
    curr_sum = 0
    for x in xl:
        curr_sum += (i - x) * (i - x)
    ans = min(ans, curr_sum)
print(ans)

n = int(eval(input()))
xl = list(map(int, input().split()))
ans = 10**9
for i in range(1, 101):
    v = 0
    for x in xl:
        v += (x - i) ** 2
    ans = min(ans, v)
print(ans)

-ans = 10**18 -for i in range(0, 101): -    curr_sum = 0 +ans = 10**9 +for i in range(1, 101): +    v = 0 -        curr_sum += (i - x) * (i - x) -    ans = min(ans, curr_sum) +        v += (x - i) ** 2 +    ans = min(ans, v)