func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int a[200000];   long long int left1[200000][2];   long long int right1[200000][2];   long long int ans[200000];   int main() {     long long int n;     cin >> n;     left1[1][0] = 0;     right1[n][0] = 0;     for (long long int i = 1; i <= n; i++) cin >> a[i];     left1[1][1] = a[1];     right1[n][1] = a[n];     for (long long int i = 2; i <= n; i++) {       left1[i][1] = max(a[i], left1[i - 1][1] + 1);       left1[i][0] = left1[i - 1][0] + (left1[i][1] - a[i]);     }     for (long long int i = n - 1; i >= 0; i--) {       right1[i][1] = max(a[i], right1[i + 1][1] + 1);       right1[i][0] = right1[i + 1][0] + right1[i][1] - a[i];     }     for (long long int i = 1; i <= n; i++)       ans[i] = left1[i - 1][0] + right1[i + 1][0] +                max(left1[i][1], right1[i][1]) - a[i];     long long int j = 1e18;     for (long long int i = 1; i <= n; i++) {       j = min(ans[i], j);     }     cout << j;   }   