#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *a = new int[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0, m = 0;
  while (1) {
    for (int i = 0; i < n; i++) {
      if (a[i] <= m) {
        m++;
        a[i] = n + 2;
      }
    }
    if (m == n) break;
    ans++;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] <= m) {
        m++;
        a[i] = n + 2;
      }
    }
    if (m == n) break;
    ans++;
  }
  cout << ans;
  return 0;
}
