func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n;   long long a[maxn], l[maxn], r[maxn], lans[maxn], rans[maxn];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     for (int i = 1; i <= n; i++) {       l[i] = max(a[i], l[i - 1] + 1);       lans[i] = l[i] - a[i] + lans[i - 1];     }     for (int i = n; i >= 0; i--) {       r[i] = max(a[i], r[i + 1] + 1);       rans[i] = r[i] - a[i] + rans[i + 1];     }     long long ans = 1e18;     for (int i = 1; i <= n; i++)       ans =           min(ans, lans[i - 1] + rans[i + 1] + max(l[i], max(r[i], a[i])) - a[i]);     printf( %I64d n , ans);     return 0;   }   