#include <bits/stdc++.h>
using namespace std;
bool Was[1001];
int main() {
  int n, A[1001];
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> A[i];
  int pos = 0;
  int sum = 0;
  if (A[pos] == 0) {
    sum++;
    Was[0] = true;
  }
  bool right = true;
  int change = 0;
  while (sum < n) {
    if (right && pos != n - 1)
      pos++;
    else {
      if (pos == n - 1) {
        pos--;
        right = false;
        change++;
      } else {
        if (pos == 0) {
          right = true;
          pos++;
          change++;
        } else
          pos--;
      }
    }
    if (A[pos] <= sum && Was[pos] == false) {
      sum++;
      Was[pos] = true;
    }
  }
  cout << change;
  return 0;
}
