#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int kol = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    int q = kol;
    if (i % 2 == 1) {
      for (int j = 1; j <= n; j++) {
        if (a[j] <= kol && a[j] != -1) kol++, a[j] = -1;
      }
      if (q == kol) return cout << ans - 1, 0;
      ans++;
    } else {
      for (int j = n; j >= 1; j--) {
        if (a[j] <= kol && a[j] != -1) kol++, a[j] = -1;
      }
      if (q == kol) return cout << ans - 1, 0;
      ans++;
    }
  }
  cout << ans - 1;
  return 0;
}
