func_code_string: #include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   int n, ans = 0;   int b[1000001];   int num;   void dfs(int u, int d) {     if (u == n) {       num = min(num, ans);       return;     }     if (abs(b[u] - b[u - 1] - d) > 1) return;     int d1 = b[u] - b[u - 1];     if (d1 < d) {       b[u]++;       ans++;       dfs(u + 1, d);       b[u]--;       ans--;     } else if (d1 > d) {       b[u]--;       ans++;       dfs(u + 1, d);       b[u]++;       ans--;     } else if (d1 == d)       dfs(u + 1, d);     return;   }   int main() {     scanf( %d , &n);     for (long long(i) = (0); (i) < (n); (i)++) scanf( %d , b + i);     num = 2e7;     dfs(1, b[1] - b[0]);     dfs(1, b[1] - b[0] + 1);     dfs(1, b[1] - b[0] - 1);     b[0]++;     ans = 1;     dfs(1, b[1] - b[0]);     dfs(1, b[1] - b[0] + 1);     dfs(1, b[1] - b[0] - 1);     b[0] -= 2;     ans = 1;     dfs(1, b[1] - b[0]);     dfs(1, b[1] - b[0] + 1);     dfs(1, b[1] - b[0] - 1);     if (num < 2e7)       printf( %d n , num);     else       puts( -1 );     return 0;   }   