a = 0
b = 0

N = int(input())
X = list(map(int, input().split()))
avg = sum(X) // N
for tai in X:
  a += (tai - avg) ** 2
for tai in X:
  b += (tai - (avg + 1)) ** 2
if a > b :
  print(b)
else :
  print(a) a = 0 a 0 b = 0 b 0 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 avg = sum(X) // N avg sum(X) // N sum(X) sum X N for tai in X:
  a += (tai - avg) ** 2 tai X a += (tai - avg) ** 2 a (tai - avg) ** 2 tai - avg tai avg 2 for tai in X:
  b += (tai - (avg + 1)) ** 2 tai X b += (tai - (avg + 1)) ** 2 b (tai - (avg + 1)) ** 2 tai - (avg + 1) tai avg + 1 avg 1 2 if a > b :
  print(b)
else :
  print(a) a > b a b print(b) print b print(a) print a a += (tai - avg) ** 2 (tai - avg) ** 2 a a = 0 0 a avg = sum(X) // N sum(X) // N avg X = list(map(int, input().split())) list(map(int, input().split())) X N = int(input()) int(input()) N b += (tai - (avg + 1)) ** 2 (tai - (avg + 1)) ** 2 b b = 0 0 b
a = 0
b = 0

N = int(input())
X = list(map(int, input().split()))
avg = sum(X) // N
for tai in X:
  a += (tai - avg) ** 2
for tai in X:
  b += (tai - (avg + 1)) ** 2
if a > b :
  print(b)
else :
  print(a)