n = int(eval(input()))

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

lia = []

for i in range(1,100):

    a = 0

    for j in range(n):

        a += (abs(li[j]-i))**2

    lia.append(a)

print((min(lia)))
n = int(eval(input()))

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

o1 = (sum(li))//n

o2 = o1 + 1

li1 = []

li2 = []

for i in range(n):

    li1.append((int(li[i]-o1))**2)

for j in range(n):

    li2.append((int(li[j]-o2))**2)

if sum(li1) >= sum(li2):

    print((sum(li2)))

else:

    print((sum(li1)))  
n = int(eval(input()))
li = list(map(int, input().split()))
lia = []
for i in range(1, 100):
    a = 0
    for j in range(n):
        a += (abs(li[j] - i)) ** 2
    lia.append(a)
print((min(lia)))

n = int(eval(input()))
li = list(map(int, input().split()))
o1 = (sum(li)) // n
o2 = o1 + 1
li1 = []
li2 = []
for i in range(n):
    li1.append((int(li[i] - o1)) ** 2)
for j in range(n):
    li2.append((int(li[j] - o2)) ** 2)
if sum(li1) >= sum(li2):
    print((sum(li2)))
else:
    print((sum(li1)))

-lia = [] -for i in range(1, 100): -    a = 0 -    for j in range(n): -        a += (abs(li[j] - i)) ** 2 -    lia.append(a) -print((min(lia))) +o1 = (sum(li)) // n +o2 = o1 + 1 +li1 = [] +li2 = [] +for i in range(n): +    li1.append((int(li[i] - o1)) ** 2) +for j in range(n): +    li2.append((int(li[j] - o2)) ** 2) +if sum(li1) >= sum(li2): +    print((sum(li2))) +else: +    print((sum(li1)))