n = int(input())
lst = [int(i) for i in input().split()]

min_n = min(lst)
max_n = max(lst)
min_count = 1000000000
for i in range(min_n, max_n + 1):
  count = 0
  for j in range(n):
    count += (lst[j] - i) ** 2
  if count < min_count:
    min_count = count
print(min_count) 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 lst = [int(i) for i in input().split()] lst [int(i) for i in input().split()] min_n = min(lst) min_n min(lst) min lst max_n = max(lst) max_n max(lst) max lst min_count = 1000000000 min_count 1000000000 for i in range(min_n, max_n + 1):
  count = 0
  for j in range(n):
    count += (lst[j] - i) ** 2
  if count < min_count:
    min_count = count i range(min_n, max_n + 1) range min_n max_n + 1 max_n 1 count = 0 count 0 for j in range(n):
    count += (lst[j] - i) ** 2
   j range(n) range n count += (lst[j] - i) ** 2 count (lst[j] - i) ** 2 lst[j] - i lst[j] lst j i 2 if count < min_count:
    min_count = count count < min_count count min_count min_count = count min_count count print(min_count) print min_count count = 0 0 count n = int(input()) int(input()) n lst = [int(i) for i in input().split()] [int(i) for i in input().split()] lst min_n = min(lst) min(lst) min_n min_count = 1000000000 1000000000 min_count min_count = count count min_count count += (lst[j] - i) ** 2 (lst[j] - i) ** 2 count max_n = max(lst) max(lst) max_n
n = int(input())
lst = [int(i) for i in input().split()]

min_n = min(lst)
max_n = max(lst)
min_count = 1000000000
for i in range(min_n, max_n + 1):
  count = 0
  for j in range(n):
    count += (lst[j] - i) ** 2
  if count < min_count:
    min_count = count
print(min_count)
