N = int(input()) A = list(map(int,input().split())) A = A+[0]*100 su = sum(A) N = int(su**0.5) ans = su - N**2 for i in range(1,2*N): ans += max(0, N - abs(N-i) - A[i-1]) print(ans)