#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, t = 0, c = 0, i, b[1001] = {0};
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] <= sum) {
      b[i]++;
      sum++;
    }
  }
  t = 1;
  while (sum != n) {
    c++;
    if (t == 1) {
      for (i = n - 1; i >= 0; i--) {
        if (b[i] == 0 && (a[i] <= sum)) {
          b[i]++;
          sum++;
        }
      }
      t = 0;
    } else {
      for (i = 0; i < n; i++) {
        if ((b[i] == 0) && (a[i] <= sum)) {
          b[i]++;
          sum++;
        }
      }
      t = 1;
    }
  }
  cout << c;
  return 0;
}
