#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> v;
  vector<bool> stat;
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    v.push_back(tmp);
    stat.push_back(false);
  }
  long long ans = 0, curr = 0, cntr = 0;
  bool dir = true;
  while (cntr < n) {
    ans++;
    if (dir) {
      for (long long i = 0; i < n; i++) {
        if (stat[i] == false) {
          if (curr >= v[i]) {
            curr++;
            stat[i] = true;
            cntr++;
          }
        }
      }
      dir = false;
    } else {
      for (long long i = n - 1; i >= 0; i--) {
        if (stat[i] == false) {
          if (curr >= v[i]) {
            curr++;
            stat[i] = true;
            cntr++;
          }
        }
      }
      dir = true;
    }
  }
  cout << ans - 1 << "\n";
  return 0;
}
