#include <bits/stdc++.h>
using namespace std;
int a[1001];
bool colour[10012];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int k = 0;
  for (int u = 0;; u++) {
    bool o = true;
    if (u % 2 == 0) {
      for (int i = 0; i < n; i++) {
        if (a[i] <= k && !colour[i]) {
          a[i] = 0;
          k++;
          colour[i] = true;
        }
        if (a[i] != 0) {
          o = false;
        }
      }
    } else {
      for (int i = n - 1; i >= 0; i--) {
        if (a[i] <= k && !colour[i]) {
          a[i] = 0;
          k++;
          colour[i] = true;
        }
        if (a[i] != 0) {
          o = false;
        }
      }
    }
    if (o) {
      cout << u << endl;
      return 0;
    }
  }
  return 0;
}
