#include <bits/stdc++.h>

using namespace std;

long long n, a[100008], i, r, m, q = 0, w = 0, p = 0, res = 0, rrr;

int main() {
    cin >> n;
    for (i = 1; i <= n; i ++) {
        cin >> a[i];
    }
    m = a[n];
    r = a[n];
    p = a[n];
    for (i = n - 1; i >= 1; i --) {
        q ++;

        p = a[i] - q;
        if (p > 0) r += p;
        m = a[i];
        
        
    }
   
    cout << r;
    
    return 0;
}