func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 1;   int mark[N], t[N], n;   long long res;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n;     for (int i = (1); i <= (n); i += (1)) cin >> mark[i];     int cur = 0;     for (int i = (n); i >= (1); i -= (1)) {       cur = max(0, cur - 1);       cur = max(cur, mark[i] + 1);       t[i] = cur;     }     cur = 0;     for (int i = (1); i <= (n); i += (1)) {       cur = max(cur, t[i]);       res += cur;     }     for (int i = (1); i <= (n); i += (1)) res -= (mark[i] + 1);     cout << res <<   n ;     return 0;   }   