#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[1012], c = 0, ans = 0, k = 0, i;
  set<int> r;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  while (r.size() < n) {
    if (k == 0) {
      for (i = 0; i < n; i++) {
        if (arr[i] == -1) continue;
        if (arr[i] <= c) {
          arr[i] = -1;
          c++;
          r.insert(i);
        }
      }
      k = 1;
      if (r.size() < n) ans++;
    } else {
      for (int i = n - 1; i >= 0; i--) {
        if (arr[i] == -1) continue;
        if (arr[i] <= c) {
          arr[i] = -1;
          c++;
          r.insert(i);
        }
      }
      k = 0;
      if (r.size() < n) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
