#include <bits/stdc++.h>
using namespace std;
const int maxen = 1e5 + 5;
int rob[maxen];
bool vis[maxen];
int main() {
  int n, fin, turn, po;
  while (cin >> n && n) {
    fin = 0, turn = 0, po = 0;
    memset(vis, false, sizeof vis);
    for (int i = 1; i <= n; i++) cin >> rob[i];
    while (fin != n) {
      for (int i = 1; i <= n; i++) {
        if (!vis[i])
          if (po >= rob[i]) {
            po++;
            vis[i] = true;
            fin++;
          }
      }
      if (fin == n)
        break;
      else
        turn++;
      for (int i = n; i > 0; i--) {
        if (!vis[i])
          if (po >= rob[i]) {
            po++;
            vis[i] = true;
            fin++;
          }
      }
      if (fin == n)
        break;
      else
        turn++;
    }
    cout << turn << endl;
  }
  return 0;
}
