func_code_string: #include <bits/stdc++.h>   using namespace std;   int m[100100];   vector<int> diff[100100];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> m[i];       diff[i - m[i]].push_back(i);     }     long long sum = 0;     int d = 0, tot = 1;     for (int i = 2; i <= n; i++) {       auto it = upper_bound(diff[d + 1].begin(), diff[d + 1].end(), i);       sum += tot - m[i];       if (it != diff[d + 1].end() || m[i] == tot)         tot++;       else {         d++;         sum--;       }     }     cout << sum << endl;     return 0;   }   