#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N];
bool used[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int dir = 0;
  int cur = 0;
  int ans = 0;
  while (true) {
    bool ok = false;
    if (dir == 0) {
      for (int i = 0; i < n; i++) {
        if (!used[i] && a[i] <= cur) {
          used[i] = true;
          cur++;
          ok = true;
        }
      }
    } else {
      for (int i = n - 1; i >= 0; i--) {
        if (!used[i] && a[i] <= cur) {
          used[i] = true;
          cur++;
          ok = true;
        }
      }
    }
    if (!ok) break;
    dir = 1 - dir;
    ans++;
  }
  cout << ans - 1 << "\n";
}
