import statistics

n=int(eval(input()))

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

num=round(statistics.mean(a))

print((sum([(num-i)**2 for i in a])))
eval(input());a=list(map(int,input().split()));r=float('inf')

for i in range(min(a),max(a)+1):

  n=0

  for j in a:

    n+=(j-i)**2

  r=min(n,r)

print(r)
import statistics

n = int(eval(input()))
a = list(map(int, input().split()))
num = round(statistics.mean(a))
print((sum([(num - i) ** 2 for i in a])))

eval(input())
a = list(map(int, input().split()))
r = float("inf")
for i in range(min(a), max(a) + 1):
    n = 0
    for j in a:
        n += (j - i) ** 2
    r = min(n, r)
print(r)

-import statistics - -n = int(eval(input())) +eval(input()) -num = round(statistics.mean(a)) -print((sum([(num - i) ** 2 for i in a]))) +r = float("inf") +for i in range(min(a), max(a) + 1): +    n = 0 +    for j in a: +        n += (j - i) ** 2 +    r = min(n, r) +print(r)