input()
l = list(map(int,input().split()))
l.sort()
ans = 1000000
n_ans = 0
for i in range(l[0],l[len(l)-1]+1):
  for j in range(len(l)):
    n_ans += (l[j]-i) ** 2
  if n_ans <= ans:
    ans = n_ans
    n_ans = 0
  else:
    n_ans = 0
print(ans) input() input l = list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split l.sort() l.sort l sort ans = 1000000 ans 1000000 n_ans = 0 n_ans 0 for i in range(l[0],l[len(l)-1]+1):
  for j in range(len(l)):
    n_ans += (l[j]-i) ** 2
  if n_ans <= ans:
    ans = n_ans
    n_ans = 0
  else:
    n_ans = 0 i range(l[0],l[len(l)-1]+1) range l[0] l 0 l[len(l)-1]+1 l[len(l)-1] l len(l)-1 len(l) len l 1 1 for j in range(len(l)):
    n_ans += (l[j]-i) ** 2
   j range(len(l)) range len(l) len l n_ans += (l[j]-i) ** 2 n_ans (l[j]-i) ** 2 l[j]-i l[j] l j i 2 if n_ans <= ans:
    ans = n_ans
    n_ans = 0
  else:
    n_ans = 0 n_ans <= ans n_ans ans ans = n_ans ans n_ans n_ans = 0 n_ans 0 n_ans = 0 n_ans 0 print(ans) print ans n_ans = 0 0 n_ans ans = n_ans n_ans ans l = list(map(int,input().split())) list(map(int,input().split())) l ans = 1000000 1000000 ans n_ans += (l[j]-i) ** 2 (l[j]-i) ** 2 n_ans n_ans = 0 0 n_ans n_ans = 0 0 n_ans
input()
l = list(map(int,input().split()))
l.sort()
ans = 1000000
n_ans = 0
for i in range(l[0],l[len(l)-1]+1):
  for j in range(len(l)):
    n_ans += (l[j]-i) ** 2
  if n_ans <= ans:
    ans = n_ans
    n_ans = 0
  else:
    n_ans = 0
print(ans)