#include <bits/stdc++.h>
using namespace std;
int a[1003];
int used[1003];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  bool toR = true;
  multiset<int> l, r;
  for (int i = 0; i < n; i++) r.insert(a[i]);
  int cur = 0, ans = 0;
  int i = 0;
  while (true) {
    if (toR) {
      if (i == -1) i++;
      for (; i < n; i++) {
        if (!r.empty() && *r.begin() > cur) break;
        if (!used[i]) {
          if (a[i] <= cur) {
            cur++;
            used[i] = true;
          } else {
            r.erase(r.find(a[i]));
            l.insert(a[i]);
          }
        }
      }
    } else {
      if (i == n) i -= 1;
      for (; i > -1; i--) {
        if (!l.empty() && *l.begin() > cur) break;
        if (!used[i]) {
          if (a[i] <= cur) {
            cur++;
            used[i] = true;
          } else {
            l.erase(l.find(a[i]));
            r.insert(a[i]);
          }
        }
      }
    }
    if (cur == n) {
      cout << ans << endl;
      return 0;
    }
    toR = !toR;
    ans++;
  }
  return 0;
}
