#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> computers;
int change;
int information;
void process2();
void process1() {
  int d1 = 1;
  while (computers.size() > 0) {
    for (int i = 0; i < computers.size(); i += d1) {
      if (computers[i] <= information) {
        information++;
        computers.erase(computers.begin() + i);
        i--;
      }
    }
    change++;
    process2();
  }
  return;
}
void process2() {
  int d1 = -1;
  while (computers.size() > 0) {
    for (int i = computers.size() - 1; i >= 0; i += d1) {
      if (computers[i] <= information) {
        information++;
        computers.erase(computers.begin() + i);
      }
    }
    change++;
    process1();
  }
  return;
}
int main() {
  int x;
  while (cin >> n) {
    change = 0;
    information = 0;
    computers.clear();
    for (int i = 0; i < n; i++) {
      cin >> x;
      computers.push_back(x);
    }
    process1();
    cout << change - 1 << endl;
  }
}
