import numpy as np

n = int(eval(input()))

a = np.array(input().split(), np.int)

a.sort()



ans = []

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

    ans.append(np.sum((a - x) ** 2))



print((min(ans)))
from decimal import Decimal, ROUND_HALF_UP

import numpy as np

n = int(eval(input()))

x = np.array(input().split(), int)



m = Decimal(np.sum(x) / n)

mq = int(m.quantize(0, rounding=ROUND_HALF_UP))



s = np.sum((x-mq)**2)

print(s)
import numpy as np

n = int(eval(input()))
a = np.array(input().split(), np.int)
a.sort()
ans = []
for x in range(a[0], a[-1] + 1):
    ans.append(np.sum((a - x) ** 2))
print((min(ans)))

from decimal import Decimal, ROUND_HALF_UP
import numpy as np

n = int(eval(input()))
x = np.array(input().split(), int)
m = Decimal(np.sum(x) / n)
mq = int(m.quantize(0, rounding=ROUND_HALF_UP))
s = np.sum((x - mq) ** 2)
print(s)

+from decimal import Decimal, ROUND_HALF_UP -a = np.array(input().split(), np.int) -a.sort() -ans = [] -for x in range(a[0], a[-1] + 1): -    ans.append(np.sum((a - x) ** 2)) -print((min(ans))) +x = np.array(input().split(), int) +m = Decimal(np.sum(x) / n) +mq = int(m.quantize(0, rounding=ROUND_HALF_UP)) +s = np.sum((x - mq) ** 2) +print(s)