n=int(input())
x=list(map(int,input().split()))
mi=min(x)
ma=max(x)
ans = sum(x)**2
for i in range (mi,ma+1):
  hp=0
  for j in x:
    hp+= (i-j)**2
  ans = min(hp,ans)
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 mi=min(x) mi min(x) min x ma=max(x) ma max(x) max x ans = sum(x)**2 ans sum(x)**2 sum(x) sum x 2 for i in range (mi,ma+1):
  hp=0
  for j in x:
    hp+= (i-j)**2
  ans = min(hp,ans) i range (mi,ma+1) range mi ma+1 ma 1 hp=0 hp 0 for j in x:
    hp+= (i-j)**2
   j x hp+= (i-j)**2 hp (i-j)**2 i-j i j 2 ans = min(hp,ans) ans min(hp,ans) min hp ans print(ans) print ans ans = min(hp,ans) min(hp,ans) ans x=list(map(int,input().split())) list(map(int,input().split())) x hp=0 0 hp mi=min(x) min(x) mi n=int(input()) int(input()) n hp+= (i-j)**2 (i-j)**2 hp ans = sum(x)**2 sum(x)**2 ans ma=max(x) max(x) ma
n=int(input())
x=list(map(int,input().split()))
mi=min(x)
ma=max(x)
ans = sum(x)**2
for i in range (mi,ma+1):
  hp=0
  for j in x:
    hp+= (i-j)**2
  ans = min(hp,ans)
print(ans)
