func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   const int maxn = 1e5 + 5;   const int inf = 0x3f3f3f3f;   const double PI = acos(-1.0);   const long long INF = 0x3f3f3f3f3f3f3f3f;   int a[maxn], val[maxn];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       val[i] = a[i] + 1;     }     for (int i = 1; i <= n; ++i) {       val[i] = max(val[i], val[i - 1]);     }     for (int i = n; i > 0; --i) {       val[i] = max(val[i + 1] - 1, val[i]);     }     long long ans = 0;     for (int i = 1; i <= n; ++i) {       ans += val[i] - a[i] - 1;     }     cout << ans << endl;     return 0;   }   