n = int(input())
x = list(map(int,input().split()))

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

m = min(x)
M = max(x)
ans = 10**9
for i in range(m,M+1):
  cost = 0
  for j in range(n):
    cost += (x[j]-i)**2
    
  ans = min(ans,cost)
print(ans)