n = int(input())
a = [int(i) for i in input().split()]
#import numpy as np
#n = 100
#a = np.random.randint(1, 100, n)
a = sorted(a)
minsum = float('inf')
for i in range(a[0], a[-1]+1):
  cnt = 0
  for ai in a:
    cnt += (ai - i)**2
  if cnt <= minsum:
    minsum = cnt
print(minsum) n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a = [int(i) for i in input().split()] a [int(i) for i in input().split()] a = sorted(a) a sorted(a) sorted a minsum = float('inf') minsum float('inf') float 'inf' for i in range(a[0], a[-1]+1):
  cnt = 0
  for ai in a:
    cnt += (ai - i)**2
  if cnt <= minsum:
    minsum = cnt i range(a[0], a[-1]+1) range a[0] a 0 a[-1]+1 a[-1] a -1 1 cnt = 0 cnt 0 for ai in a:
    cnt += (ai - i)**2
   ai a cnt += (ai - i)**2 cnt (ai - i)**2 ai - i ai i 2 if cnt <= minsum:
    minsum = cnt cnt <= minsum cnt minsum minsum = cnt minsum cnt print(minsum) print minsum n = int(input()) int(input()) n minsum = float('inf') float('inf') minsum cnt = 0 0 cnt a = [int(i) for i in input().split()] [int(i) for i in input().split()] a minsum = cnt cnt minsum a = sorted(a) sorted(a) a cnt += (ai - i)**2 (ai - i)**2 cnt
n = int(input())
a = [int(i) for i in input().split()]
#import numpy as np
#n = 100
#a = np.random.randint(1, 100, n)
a = sorted(a)
minsum = float('inf')
for i in range(a[0], a[-1]+1):
  cnt = 0
  for ai in a:
    cnt += (ai - i)**2
  if cnt <= minsum:
    minsum = cnt
print(minsum)