func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = 4e18;   const long long N = 2e5 + 10;   void testCase() {     long long n;     cin >> n;     long long a[n + 1];     for (long long i = 1; i <= n; i++) cin >> a[i];     vector<long long> sma(n + 2), suf(n + 2);     for (long long i = n; i >= 1; i--) {       sma[i] = max(a[i], sma[i + 1] + 1);       suf[i] = suf[i + 1] + sma[i] - a[i];     }     long long ans = inf;     long long pma = 0, pref = 0;     for (long long i = 1; i <= n; i++) {       pma = max(pma + 1, a[i]);       long long cur = pref + suf[i + 1] + max(pma, sma[i]) - a[i];       ans = min(ans, cur);       pref += pma - a[i];     }     cout << ans;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);     long long t_c = 1;     while (t_c--) testCase();   }   