#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, points = 0, change = 0;
  cin >> N;
  int computer[N], col[N];
  for (int i = 0; i < N; i++) {
    cin >> computer[i];
    if (computer[i] <= points) {
      points++;
      col[i] = 1;
    } else {
      col[i] = 0;
    }
  }
  while (points < N) {
    if (change % 2 == 0) {
      for (int i = N - 1; i >= 0; i--) {
        if (col[i] == 0 && computer[i] <= points) {
          points++;
          col[i] = 1;
        }
      }
    } else {
      for (int i = 0; i < N; i++) {
        if (col[i] == 0 && computer[i] <= points) {
          points++;
          col[i] = 1;
        }
      }
    }
    change++;
  }
  cout << change << endl;
}
