#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 1;
int ar[maxn];
int vis[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> ar[i];
  int ans = 0;
  int i = 0;
  int done = 0;
  int dir = -1;
  while (1) {
    if (!vis[i] && ar[i] <= done) {
      vis[i] = 1;
      ++done;
    }
    if (done == n) break;
    if (i == n - 1 || i == 0) {
      dir = -dir;
      ans++;
    }
    i += dir;
  }
  int add = 1;
  if (n == 1) add = 0;
  cout << ans - add;
  return 0;
}
