#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<bool> st(n + 1, false);
  bool fwd = true;
  int counter = 0, i = 0;
  for (; counter < n; i++) {
    if (fwd) {
      for (int j = 0; j < n; j++) {
        if (v[j] <= counter && !st[j]) {
          st[j] = true;
          counter++;
        }
      }
      fwd = !fwd;
    } else {
      for (int j = n - 1; j >= 0; j--) {
        if (v[j] <= counter && !st[j]) {
          st[j] = true;
          counter++;
        }
      }
      fwd = !fwd;
    }
  }
  if (i == 1)
    cout << 0 << "\n";
  else
    cout << (i - 1) << "\n";
  return 0;
}
