n = int(input()) a = list(map(int,input().split())) s = sum(a) t = int(s**0.5) b = [i+1 for i in range(t)] + [i for i in range(t-1, 0, -1)] c = 0 for i in range(min(len(a), len(b))): c += min(a[i], b[i]) d = s - c print(d)