func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( tune=native )   using namespace std;   const int MAX = 1e6 + 5;   const long long MOD = 1000000007;   const long long MOD2 = 2010405347;   const long long INF = 2e18;   const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};   const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};   const double pi = acos(-1);   const double EPS = 1e-9;   const int block = 315;   inline long long pw(long long x, long long y, long long md = MOD) {     long long ret = 1;     while (y) {       if (y & 1) ret = ret * x % md;       x = x * x % md, y >>= 1;     }     return ret;   }   int n, x[MAX], y[MAX], z[MAX], nw;   long long ans;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = (1); i <= (n); ++i) {       cin >> x[i];       y[i] = max(y[i - 1], x[i] + 1);     }     for (int i = (n); i >= (1); --i) {       nw = max(nw - 1, x[i] + 1);       z[i] = nw;     }     for (int i = (1); i <= (n); ++i) {       nw = max(y[i], z[i]);       ans += nw - x[i] - 1;     }     cout << ans <<   n ;     return 0;   }   