n = int(input())
aaa = list(map(int, input().split(' ')))
center = sum(aaa) // n
ans = 99999999999999999
for i in [-1, 0, 1]:
  ans = min(ans, sum([(a - center + i) ** 2 for a in aaa]))
  
print(ans) n = int(input()) n int(input()) int input() input aaa = list(map(int, input().split(' '))) aaa list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' center = sum(aaa) // n center sum(aaa) // n sum(aaa) sum aaa n ans = 99999999999999999 ans 99999999999999999 for i in [-1, 0, 1]:
  ans = min(ans, sum([(a - center + i) ** 2 for a in aaa]))
   i [-1, 0, 1] -1 0 1 (a - center + i) ** 2 for a in aaa for a in aaa a aaa for a in aaa (a - center + i) ** 2 a - center + i a - center a center i 2 ans = min(ans, sum([(a - center + i) ** 2 for a in aaa])) ans min(ans, sum([(a - center + i) ** 2 for a in aaa])) min ans sum([(a - center + i) ** 2 for a in aaa]) sum [(a - center + i) ** 2 for a in aaa] print(ans) print ans aaa = list(map(int, input().split(' '))) list(map(int, input().split(' '))) aaa ans = 99999999999999999 99999999999999999 ans center = sum(aaa) // n sum(aaa) // n center n = int(input()) int(input()) n ans = min(ans, sum([(a - center + i) ** 2 for a in aaa])) min(ans, sum([(a - center + i) ** 2 for a in aaa])) ans
n = int(input())
aaa = list(map(int, input().split(' ')))
center = sum(aaa) // n
ans = 99999999999999999
for i in [-1, 0, 1]:
  ans = min(ans, sum([(a - center + i) ** 2 for a in aaa]))
  
print(ans)