n=int(input())
x=list(map(int,input().split()))
x.sort()
ans,count=[],0

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

for i in range(x[0],x[-1]+1):
  for j in x:
    count+=(j-i)**2
    
  ans.append(count)
  count=0
  
print(min(ans))