#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long count = 0;
  long long i = 0;
  long long ans = 0;
  unordered_set<long long> s;
  while (count < n) {
    ans++;
    if (i == 0 || i == -1) {
      for (i = 0; i < n; i++) {
        if (arr[i] <= count && s.find(i) == s.end()) {
          count++;
          s.insert(i);
        }
      }
    } else if (i == n) {
      for (i = n - 1; i >= 0; i--) {
        if (arr[i] <= count && s.find(i) == s.end()) {
          count++;
          s.insert(i);
        }
      }
    }
  }
  cout << ans - 1 << endl;
}
