n=int(input()) a=[int(i) for i in input().split()]+[0]*100 s=sum(a) h=1 while (h+1)*(h+1)<=s: h+=1 p=0 for i in range(h-1): j=i+1 if a[i]>j: p+=a[i]-j k=2*h-i-2 if a[k]>j: p+=a[k]-j c=h-1 if a[c]>h: p+=a[c]-h print(p+sum(a[2*h-1:]))