#include <bits/stdc++.h>
using namespace std;
int a[1010];
bool mark[1010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int loc = 0, in = 0, g = 0;
  while (true) {
    if (loc == 0)
      for (int i = 0; i < n; i++)
        if (a[i] <= in && !mark[i]) {
          mark[i] = true;
          in++;
        }
    if (loc == 1)
      for (int i = n - 1; i >= 0; i--)
        if (a[i] <= in && !mark[i]) {
          mark[i] = true;
          in++;
        }
    int h = 0;
    for (int i = 0; i < n; i++)
      if (mark[i]) h++;
    if (h == n) break;
    loc = 1 - loc;
    g++;
  }
  cout << g;
  return 0;
}
