import math
N = int(input())
lst = list(map(int, input().split()))
X = math.floor(sum(lst)/N + 0.5)
ans = 0
for i in lst:
    ans = ans + (X - i)**2

print(ans) import math math N = int(input()) N int(input()) int input() input lst = list(map(int, input().split())) lst list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split X = math.floor(sum(lst)/N + 0.5) X math.floor(sum(lst)/N + 0.5) math.floor math floor sum(lst)/N + 0.5 sum(lst)/N sum(lst) sum lst N 0.5 ans = 0 ans 0 for i in lst:
    ans = ans + (X - i)**2 i lst ans = ans + (X - i)**2 ans ans + (X - i)**2 ans (X - i)**2 X - i X i 2 print(ans) print ans lst = list(map(int, input().split())) list(map(int, input().split())) lst ans = ans + (X - i)**2 ans + (X - i)**2 ans X = math.floor(sum(lst)/N + 0.5) math.floor(sum(lst)/N + 0.5) X ans = 0 0 ans N = int(input()) int(input()) N
import math
N = int(input())
lst = list(map(int, input().split()))
X = math.floor(sum(lst)/N + 0.5)
ans = 0
for i in lst:
    ans = ans + (X - i)**2

print(ans)