func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 5;   long long v[N], mn[N];   int main() {     long long n;     long long ans = 0;     cin >> n;     for (long long i = 0; i < n; i++) cin >> v[i];     for (long long i = 0; i < n; i++) mn[i] = v[i] + 1;     for (long long i = 1; i < n; i++) mn[i] = max(mn[i - 1], mn[i]);     for (long long i = n - 2; i >= 0; i--) mn[i] = max(mn[i], mn[i + 1] - 1);     for (long long i = 0; i < n; i++) ans += mn[i] - v[i] - 1;     cout << ans << endl;   }   