n=int(input())
x=[int(x) for x in input().split()]
ave1=sum(x)//n
ave2=ave1+1
a=0
b=0
for j in x:
  a+=(j-ave1)**2
  b+=(j-ave2)**2
print(min(a,b)) n=int(input()) n int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x x=[int(x) for x in input().split()] x [int(x) for x in input().split()] ave1=sum(x)//n ave1 sum(x)//n sum(x) sum x n ave2=ave1+1 ave2 ave1+1 ave1 1 a=0 a 0 b=0 b 0 for j in x:
  a+=(j-ave1)**2
  b+=(j-ave2)**2 j x a+=(j-ave1)**2 a (j-ave1)**2 j-ave1 j ave1 2 b+=(j-ave2)**2 b (j-ave2)**2 j-ave2 j ave2 2 print(min(a,b)) print min(a,b) min a b a+=(j-ave1)**2 (j-ave1)**2 a n=int(input()) int(input()) n ave2=ave1+1 ave1+1 ave2 b=0 0 b x=[int(x) for x in input().split()] [int(x) for x in input().split()] x ave1=sum(x)//n sum(x)//n ave1 a=0 0 a b+=(j-ave2)**2 (j-ave2)**2 b
n=int(input())
x=[int(x) for x in input().split()]
ave1=sum(x)//n
ave2=ave1+1
a=0
b=0
for j in x:
  a+=(j-ave1)**2
  b+=(j-ave2)**2
print(min(a,b))