#include <bits/stdc++.h>
using namespace std;
enum Direction { Left, Right };
int main() {
  int n, a, b;
  cin >> n;
  vector<int> vec(n);
  vector<bool> bvec(n, true);
  int count = 0;
  int m = 0;
  int all = n;
  Direction dir = Right;
  for (int i = 0; i < n; cin >> vec[i++])
    ;
  int i = 0;
  while (true) {
    if (vec[i] <= m && bvec[i]) {
      bvec[i] = false;
      m++;
      --all;
    }
    if (!all) break;
    if (dir == Right && i == n - 1) {
      dir = Left;
      ++count;
    }
    if (dir == Left && i == 0) {
      dir = Right;
      ++count;
    }
    if (dir == Right)
      ++i;
    else
      --i;
  }
  cout << count;
  return 0;
}
