#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, k = 0, l = 0, d = 0;
  cin >> n;
  vector<long long> a(n), b(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  while (l < n) {
    d++;
    long long s = 0, e = n;
    for (i = 0; i < n; i++) {
      if (a[i] <= l && a[i] != -1) {
        l++;
        a[i] = -1;
      }
    }
    if (l == n) break;
    d++;
    for (i = n - 1; i >= 0; i--) {
      if (a[i] <= l && a[i] != -1) {
        l++;
        a[i] = -1;
      }
    }
  }
  if (d > 0) d--;
  cout << d;
}
