N = int(input())
s = list(map(int , input().split()))
list.sort(s , reverse = True)
L = [10**10]
for p in range(min(s) , max(s) + 1):
  a = 0
  b = L[0]
  for i in range(N):
    if a < b:
      a += (s[i] - p) ** 2
  if a < b:
    L[0] = a
print(L[0]) N = int(input()) N int(input()) int input() input s = list(map(int , input().split())) s list(map(int , input().split())) list map(int , input().split()) map int input().split() ().split () input split list.sort(s , reverse = True) list.sort list sort s reverse = True reverse True L = [10**10] L [10**10] 10**10 10 10 for p in range(min(s) , max(s) + 1):
  a = 0
  b = L[0]
  for i in range(N):
    if a < b:
      a += (s[i] - p) ** 2
  if a < b:
    L[0] = a p range(min(s) , max(s) + 1) range min(s) min s max(s) + 1 max(s) max s 1 a = 0 a 0 b = L[0] b L[0] L 0 for i in range(N):
    if a < b:
      a += (s[i] - p) ** 2
   i range(N) range N if a < b:
      a += (s[i] - p) ** 2
   a < b a b a += (s[i] - p) ** 2 a (s[i] - p) ** 2 s[i] - p s[i] s i p 2 if a < b:
    L[0] = a a < b a b L[0] = a L[0] L 0 a print(L[0]) print L[0] L 0 s = list(map(int , input().split())) list(map(int , input().split())) s a += (s[i] - p) ** 2 (s[i] - p) ** 2 a L = [10**10] [10**10] L b = L[0] L[0] b a = 0 0 a N = int(input()) int(input()) N
N = int(input())
s = list(map(int , input().split()))
list.sort(s , reverse = True)
L = [10**10]
for p in range(min(s) , max(s) + 1):
  a = 0
  b = L[0]
  for i in range(N):
    if a < b:
      a += (s[i] - p) ** 2
  if a < b:
    L[0] = a
print(L[0])