func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, a[1231231];   long long mark[1231231];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     mark[1] = 1;     for (int i = 2; i <= n; i++) {       mark[i] = mark[i - 1];       mark[i] = max(mark[i], a[i] + 1);     }     for (int i = n - 1; i >= 1; i--) {       mark[i] = max(mark[i], mark[i + 1] - 1);     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       ans += max(0ll, (mark[i] - 1 - a[i]));     }     cout << ans << endl;   }   