N = int(input())
X = list(map(int, input().split()))
assert len(X) == N
# N人が点Xiに住んでいる
# 任意の整数値の点で集会を開く
# 2乗距離の体力を消耗

# 点yで集会
def sum_power(y):
  return sum([(x - y) * (x - y) for x in X])

import sys
minimum = sys.maxsize
for y in range(min(X), max(X)+1):
  minimum = min(minimum, sum_power(y))
print(minimum) N = int(input()) N int(input()) int 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 assert len(X) == N len(X) == N len(X) len X N def sum_power(y):
  return sum([(x - y) * (x - y) for x in X]) sum_power (x - y) * (x - y) for x in X for x in X x X for x in X (x - y) * (x - y) x - y x y x - y x y return sum([(x - y) * (x - y) for x in X]) sum([(x - y) * (x - y) for x in X]) sum [(x - y) * (x - y) for x in X] y y import sys sys minimum = sys.maxsize minimum sys.maxsize sys maxsize for y in range(min(X), max(X)+1):
  minimum = min(minimum, sum_power(y)) y range(min(X), max(X)+1) range min(X) min X max(X)+1 max(X) max X 1 minimum = min(minimum, sum_power(y)) minimum min(minimum, sum_power(y)) min minimum sum_power(y) sum_power y print(minimum) print minimum X = list(map(int, input().split())) list(map(int, input().split())) X minimum = min(minimum, sum_power(y)) min(minimum, sum_power(y)) minimum N = int(input()) int(input()) N minimum = sys.maxsize sys.maxsize minimum def sum_power(y):
  return sum([(x - y) * (x - y) for x in X]) def sum_power(y):
  return sum([(x - y) * (x - y) for x in X]) sum_power
N = int(input())
X = list(map(int, input().split()))
assert len(X) == N
# N人が点Xiに住んでいる
# 任意の整数値の点で集会を開く
# 2乗距離の体力を消耗

# 点yで集会
def sum_power(y):
  return sum([(x - y) * (x - y) for x in X])

import sys
minimum = sys.maxsize
for y in range(min(X), max(X)+1):
  minimum = min(minimum, sum_power(y))
print(minimum)