#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> c(n, 0);
  for (long long i = 0; i < n; ++i) cin >> c[i];
  long long parts = 0, ub = n, changes = 0;
  while (ub) {
    for (long long i = 0; i < n; ++i)
      if (c[i] != -1 && c[i] <= parts) {
        c[i] = -1;
        --ub;
        ++parts;
      }
    if (ub) {
      ++changes;
      for (long long i = n - 1; i > -1; --i)
        if (c[i] != -1 && c[i] <= parts) {
          c[i] = -1;
          --ub;
          ++parts;
        }
    }
    if (ub) ++changes;
  }
  cout << changes;
  return 0;
}
