#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long M = 1e9 + 7;
const long long N = 5e5;
const long long INF = 1e9 + 1;
long long n, a[N], x[N], res, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int j = 1; j <= n; ++j) {
    for (int i = 1; i <= n; ++i) {
      if (x[i] != 1 && ans >= a[i]) {
        x[i] = 1;
        ans++;
      }
    }
    if (ans == n) {
      break;
    }
    res++;
    for (int i = n; i >= 1; --i) {
      if (x[i] != 1 && ans >= a[i]) {
        x[i] = 1;
        ans++;
      }
    }
    if (ans == n) {
      break;
    }
    res++;
  }
  cout << res;
  return 0;
}
