n = int(input())
L = list(map(int,input().split()))
l,r,ans = min(L),max(L),10**18

for i in range(l,r+1):
  total = 0
  for l in L:
    total += (l-i)**2
  ans = min(ans, total)
print(ans) n = int(input()) n int(input()) int input() input L = list(map(int,input().split())) L list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split l,r,ans = min(L),max(L),10**18 l min(L) min L r max(L) max L ans 10**18 10 18 for i in range(l,r+1):
  total = 0
  for l in L:
    total += (l-i)**2
  ans = min(ans, total) i range(l,r+1) range l r+1 r 1 total = 0 total 0 for l in L:
    total += (l-i)**2
   l L total += (l-i)**2 total (l-i)**2 l-i l i 2 ans = min(ans, total) ans min(ans, total) min ans total print(ans) print ans ans = min(L),max(L),10**18 10**18 ans n = int(input()) int(input()) n r,ans = min(L),max(L),10**18 max(L) r L = list(map(int,input().split())) list(map(int,input().split())) L total += (l-i)**2 (l-i)**2 total l,r,ans = min(L),max(L),10**18 min(L) l total = 0 0 total ans = min(ans, total) min(ans, total) ans
n = int(input())
L = list(map(int,input().split()))
l,r,ans = min(L),max(L),10**18

for i in range(l,r+1):
  total = 0
  for l in L:
    total += (l-i)**2
  ans = min(ans, total)
print(ans)