N=int(input())
X=[int(x) for x in input().split()]

ans=10**9
for p in range(-200, 200):
  ref=0
  for x in X:
    ref+=(x-p)**2
  #print(ref)
  ans=min(ans, ref)
  
print(ans) N=int(input()) N int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x X=[int(x) for x in input().split()] X [int(x) for x in input().split()] ans=10**9 ans 10**9 10 9 for p in range(-200, 200):
  ref=0
  for x in X:
    ref+=(x-p)**2
  #print(ref)
  ans=min(ans, ref)
   p range(-200, 200) range -200 200 ref=0 ref 0 for x in X:
    ref+=(x-p)**2
  #print(ref)
   x X ref+=(x-p)**2 ref (x-p)**2 x-p x p 2 ans=min(ans, ref) ans min(ans, ref) min ans ref print(ans) print ans ans=10**9 10**9 ans ans=min(ans, ref) min(ans, ref) ans N=int(input()) int(input()) N X=[int(x) for x in input().split()] [int(x) for x in input().split()] X ref=0 0 ref ref+=(x-p)**2 (x-p)**2 ref
N=int(input())
X=[int(x) for x in input().split()]

ans=10**9
for p in range(-200, 200):
  ref=0
  for x in X:
    ref+=(x-p)**2
  #print(ref)
  ans=min(ans, ref)
  
print(ans)