n = int(input())
x = list(map(int, input().split()))
x.sort()
res = 10**7
for i in range(x[0],x[-1]+1):
  tmp = 0
  for j in x:
    tmp += (j-i)**2
  res = min(tmp,res)
print(res) 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 x.sort() x.sort x sort res = 10**7 res 10**7 10 7 for i in range(x[0],x[-1]+1):
  tmp = 0
  for j in x:
    tmp += (j-i)**2
  res = min(tmp,res) i range(x[0],x[-1]+1) range x[0] x 0 x[-1]+1 x[-1] x -1 1 tmp = 0 tmp 0 for j in x:
    tmp += (j-i)**2
   j x tmp += (j-i)**2 tmp (j-i)**2 j-i j i 2 res = min(tmp,res) res min(tmp,res) min tmp res print(res) print res res = 10**7 10**7 res tmp += (j-i)**2 (j-i)**2 tmp x = list(map(int, input().split())) list(map(int, input().split())) x n = int(input()) int(input()) n res = min(tmp,res) min(tmp,res) res tmp = 0 0 tmp
n = int(input())
x = list(map(int, input().split()))
x.sort()
res = 10**7
for i in range(x[0],x[-1]+1):
  tmp = 0
  for j in x:
    tmp += (j-i)**2
  res = min(tmp,res)
print(res)