N = int(input())
A = list(map(int, input().split()))
S = sum(A)
x = round(S/N)
ans = 0
for i in range(N):
  ans += (A[i] - x)**2
print(ans)
 N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split S = sum(A) S sum(A) sum A x = round(S/N) x round(S/N) round S/N S N ans = 0 ans 0 for i in range(N):
  ans += (A[i] - x)**2 i range(N) range N ans += (A[i] - x)**2 ans (A[i] - x)**2 A[i] - x A[i] A i x 2 print(ans) print ans N = int(input()) int(input()) N ans = 0 0 ans x = round(S/N) round(S/N) x ans += (A[i] - x)**2 (A[i] - x)**2 ans S = sum(A) sum(A) S A = list(map(int, input().split())) list(map(int, input().split())) A
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
x = round(S/N)
ans = 0
for i in range(N):
  ans += (A[i] - x)**2
print(ans)

