#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  long long a[n];
  for (long long i = 0; i < n; i++) scanf("%lld", &a[i]);
  long long turns = 0;
  long long cnt = 0;
  while (cnt != n) {
    if (turns % 2 == 0) {
      for (long long i = 0; i < n; i++) {
        if (a[i] <= cnt) {
          a[i] = n + 10;
          cnt++;
        }
      }
    } else {
      for (long long i = n - 1; i >= 0; i--) {
        if (a[i] <= cnt) {
          a[i] = n + 10;
          cnt++;
        }
      }
    }
    turns++;
  }
  cout << turns - 1 << endl;
  return 0;
}
