func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10;   const int maxn5 = 3e5 + 10;   const int maxn3 = 1e3 + 10;   const long long mod = 1e9 + 7;   const long long inf = 2e18;   int a[maxn5], righ[24][maxn5], lef[24][maxn5];   int mn[18][maxn5], mx[18][maxn5], n, ans[maxn5], l[maxn5], r[maxn5];   void rmq(int k) {     for (int i = 0; i < 3 * n; i++) {       mn[0][i] = i - lef[k][i % n];       mx[0][i] = i + righ[k][i % n];     }     for (int i = 1; i < 18; i++) {       for (int j = 0; j < 3 * n and (j + (1 << i) - 1) < 3 * n; j++) {         mn[i][j] = min(mn[i - 1][j], mn[i - 1][j + (1 << (i - 1))]);         mx[i][j] = max(mx[i - 1][j], mx[i - 1][j + (1 << (i - 1))]);       }     }     return;   }   int get_left(int l, int r) {     int k = 31 - __builtin_clz(r - l + 1);     return min(mn[k][l], mn[k][r - (1 << k) + 1]);   }   int get_right(int l, int r) {     int k = 31 - __builtin_clz(r - l + 1);     return max(mx[k][l], mx[k][r - (1 << k) + 1]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < 3 * n; i++) lef[0][i] = a[i % n], righ[0][i] = a[i % n];     for (int i = 1; i < 18; i++) {       rmq(i - 1);       for (int j = 0; j < n; j++) {         if (lef[i - 1][j] >= n or righ[i - 1][j] >= n) {           lef[i][j] = maxn;           righ[i][j] = maxn;           continue;         }         lef[i][j] =             n + j - get_left(n + j - lef[i - 1][j], n + j + righ[i - 1][j]);         righ[i][j] =             get_right(n + j - lef[i - 1][j], n + j + righ[i - 1][j]) - j - n;       }     }     for (int i = 0; i < n; i++) l[i] = i + n, r[i] = i + n;     for (int i = 17; i >= 0; i--) {       rmq(i);       for (int j = 0; j < n; j++)         if (get_right(l[j], r[j]) - get_left(l[j], r[j]) < n) {           int a = get_left(l[j], r[j]);           int b = get_right(l[j], r[j]);           l[j] = a, r[j] = b;           ans[j] += (1 << i);         }     }     for (int i = 0; i < n; i++)       cout << ans[i] + (r[i] - l[i] < n - 1 ? 1 : 0) <<    ;     return 0;   }   