from math import sqrt N = int(input()) blocks = [int(i) for i in input().split()] total = sum(blocks) n = int(sqrt(total)) plus = 0 for i in range(n): if i < N: plus += max(blocks[i] - (i + 1), 0) for i in range(n, 2*n-1): if i < N: plus += max(blocks[i] - (2*n-1 - i), 0) # 作るピラミッド列よりも与えられたブロック数が多い場合 if 2*n-1 <= N: for i in range(2*n-1, N): plus += blocks[i] print(plus)