#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  vector<int> b;
  for (int i = 0; i < n; i++) {
    int q;
    cin >> q;
    a.push_back(q);
    b.push_back(0);
  }
  int k = 0, u = 0;
  int z = 1;
  while (k != n) {
    for (int i = 0; i < n; i++) {
      int o;
      if (z > 0)
        o = i;
      else
        o = n - i - 1;
      if (b[o] != 1 && a[o] <= k) {
        b[o] = 1;
        k++;
      }
    }
    z *= -1;
    if (k != n) u++;
  }
  cout << u;
  return 0;
}
