n=int(eval(input()))

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



x.sort()



for p in range(x[0],x[len(x)-1]+1):

    psum=0

    for i in range(len(x)):

        psum=psum+(x[0]-x[i])**2

#    print(psum)

    pmin=psum    

    for j in range(x[0]+1,x[len(x)-1]):

        psum=0

        for i in range(len(x)):

            psum=psum+(j-x[i])**2

#        print(psum)

        if pmin>psum:

            pmin=psum

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

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



x.sort()



psum=0

for i in range(len(x)):

    psum=psum+(x[0]-x[i])**2

#    print(psum)

pmin=psum    

for j in range(x[0]+1,x[len(x)-1]):

    psum=0

    for i in range(len(x)):

        psum=psum+(j-x[i])**2

#        print(psum)

    if pmin>psum:

        pmin=psum

print(pmin)            

n = int(eval(input()))
x = list(map(int, input().split()))
x.sort()
for p in range(x[0], x[len(x) - 1] + 1):
    psum = 0
    for i in range(len(x)):
        psum = psum + (x[0] - x[i]) ** 2
    #    print(psum)
    pmin = psum
    for j in range(x[0] + 1, x[len(x) - 1]):
        psum = 0
        for i in range(len(x)):
            psum = psum + (j - x[i]) ** 2
        #        print(psum)
        if pmin > psum:
            pmin = psum
print(pmin)

n = int(eval(input()))
x = list(map(int, input().split()))
x.sort()
psum = 0
for i in range(len(x)):
    psum = psum + (x[0] - x[i]) ** 2
#    print(psum)
pmin = psum
for j in range(x[0] + 1, x[len(x) - 1]):
    psum = 0
    for i in range(len(x)):
        psum = psum + (j - x[i]) ** 2
    #        print(psum)
    if pmin > psum:
        pmin = psum
print(pmin)

-for p in range(x[0], x[len(x) - 1] + 1): +psum = 0 +for i in range(len(x)): +    psum = psum + (x[0] - x[i]) ** 2 +#    print(psum) +pmin = psum +for j in range(x[0] + 1, x[len(x) - 1]): -        psum = psum + (x[0] - x[i]) ** 2 -    #    print(psum) -    pmin = psum -    for j in range(x[0] + 1, x[len(x) - 1]): -        psum = 0 -        for i in range(len(x)): -            psum = psum + (j - x[i]) ** 2 -        #        print(psum) -        if pmin > psum: -            pmin = psum +        psum = psum + (j - x[i]) ** 2 +    #        print(psum) +    if pmin > psum: +        pmin = psum