#include <bits/stdc++.h>
using namespace std;
int arr[10005];
int b[10005];
int mx = -1000;
vector<pair<int, int> > v;
int main() {
  int n, i, k;
  int fl4 = 0;
  int fl5 = 0;
  int sum = 0;
  int fl = 0;
  int cnt = 0;
  int cnt2 = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    v.push_back(make_pair(arr[i], i));
  }
  sort(v.begin(), v.end());
  int x = v[n - 1].second;
  if (n == 1)
    cout << 0 << endl;
  else {
    while (1) {
      if (fl == 0) {
        for (i = 0; i < n; i++) {
          if (arr[i] != -1 && arr[i] <= sum) {
            sum++;
            arr[i] = -1;
            cnt2++;
          }
        }
        fl = 1;
      } else {
        for (i = n - 1; i >= 0; i--) {
          if (arr[i] != -1 && arr[i] <= sum) {
            sum++;
            arr[i] = -1;
            cnt2++;
          }
        }
        fl = 0;
      }
      cnt++;
      if (cnt2 == n) break;
    }
    cout << cnt - 1 << endl;
  }
}
