input()
x=list(map(int,input().split()))
r=10**10
for i in range(min(x),max(x)+1):
	s=0
	for j in x:
		s+=(i-j)**2
	r=min(r,s)
print(r) input() input x=list(map(int,input().split())) x list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split r=10**10 r 10**10 10 10 for i in range(min(x),max(x)+1):
	s=0
	for j in x:
		s+=(i-j)**2
	r=min(r,s) i range(min(x),max(x)+1) range min(x) min x max(x)+1 max(x) max x 1 s=0 s 0 for j in x:
		s+=(i-j)**2
	 j x s+=(i-j)**2 s (i-j)**2 i-j i j 2 r=min(r,s) r min(r,s) min r s print(r) print r r=10**10 10**10 r s+=(i-j)**2 (i-j)**2 s r=min(r,s) min(r,s) r s=0 0 s x=list(map(int,input().split())) list(map(int,input().split())) x
input()
x=list(map(int,input().split()))
r=10**10
for i in range(min(x),max(x)+1):
	s=0
	for j in x:
		s+=(i-j)**2
	r=min(r,s)
print(r)