#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, res = 0, a[2001], sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  i = 0;
  while (sum < n) {
    if (i == 0) {
      for (i = 0; i < n; i++)
        if (a[i] <= sum) sum++, a[i] = 1000000;
      i = n - 1;
    } else {
      for (i = n - 1; i >= 0; i--)
        if (a[i] <= sum) sum++, a[i] = 1000000;
      i = 0;
    }
    res++;
  }
  cout << res - 1 << endl;
  return 0;
}
