# -*- coding: utf-8 -*-
N = int(input())
X = list(map(int, input().split()))

min_x = X[0]
max_x = X[0]
for i in range(N):
  if X[i] > max_x: max_x = X[i]
  if X[i] < min_x: min_x = X[i]

ans = 10000000
for p in range(min_x, max_x+1):
  ans_p = 0
  for x in X:
    ans_p += (x-p)**2
  if ans > ans_p: ans = ans_p

print(ans) 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 min_x = X[0] min_x X[0] X 0 max_x = X[0] max_x X[0] X 0 for i in range(N):
  if X[i] > max_x: max_x = X[i]
  if X[i] < min_x: min_x = X[i] i range(N) range N if X[i] > max_x: max_x = X[i]
   X[i] > max_x X[i] X i max_x if X[i] < min_x: min_x = X[ X[i] < min_x X[i] X i min_x ans = 10000000 ans 10000000 for p in range(min_x, max_x+1):
  ans_p = 0
  for x in X:
    ans_p += (x-p)**2
  if ans > ans_p: ans = ans_p p range(min_x, max_x+1) range min_x max_x+1 max_x 1 ans_p = 0 ans_p 0 for x in X:
    ans_p += (x-p)**2
   x X ans_p += (x-p)**2 ans_p (x-p)**2 x-p x p 2 if ans > ans_p: ans = ans ans > ans_p ans ans_p print(ans) print ans N = int(input()) int(input()) N X = list(map(int, input().split())) list(map(int, input().split())) X min_x = X[0] X[0] min_x ans_p += (x-p)**2 (x-p)**2 ans_p max_x = X[0] X[0] max_x ans = 10000000 10000000 ans ans_p = 0 0 ans_p
# -*- coding: utf-8 -*-
N = int(input())
X = list(map(int, input().split()))

min_x = X[0]
max_x = X[0]
for i in range(N):
  if X[i] > max_x: max_x = X[i]
  if X[i] < min_x: min_x = X[i]

ans = 10000000
for p in range(min_x, max_x+1):
  ans_p = 0
  for x in X:
    ans_p += (x-p)**2
  if ans > ans_p: ans = ans_p

print(ans)