func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1010;   int n, a[N], ans;   bool vis[N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int now = 1, dir = 0, tot = 0;     while (tot < n) {       if (dir == 0) {         for (int i = now; i <= n; i++)           if (!vis[i] && tot >= a[i]) {             vis[i] = 1;             tot++;           }         now = n;         dir = 1;         if (tot < n) ans++;       } else {         for (int i = now; i >= 1; i--)           if (!vis[i] && tot >= a[i]) {             vis[i] = 1;             tot++;           }         now = 1;         dir = 0;         if (tot < n) ans++;       }     }     printf( %d n , ans);     return 0;   }   