#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
enum { base = int(1e9) + 7 };
enum { N = 10001, K = 10001 };
enum { INF = int(1e9) };
int main() {
  int n;
  cin >> n;
  int a[N];
  for (int i = 0; i < n; i++) cin >> a[i];
  int curr = 0;
  bool flag[N] = {0};
  for (int iter = 0; iter <= n; iter++) {
    if (curr == n) {
      cout << iter - 1;
      return 0;
    }
    if (iter % 2 == 0) {
      for (int i = 0; i < n; i++)
        if ((!flag[i]) && a[i] <= curr) {
          curr++;
          flag[i] = true;
        }
    } else {
      for (int i = n - 1; i >= 0; i--)
        if ((!flag[i]) && a[i] <= curr) {
          curr++;
          flag[i] = true;
        }
    }
  }
  return 0;
}
