def A():
    for i in range(len(box)-1):
        box[i]-=1
count = int(input())
box=list(map(int,input().split()))
sum=0
while len(box)>0:
    sum+=box[-1]
    box=box[0:len(box)-1]
    A()
print(sum) 