#include <bits/stdc++.h>
int ar[1001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &ar[i]);
  int cnt = 0, mov;
  for (mov = 1;; mov++) {
    if (mov & 1) {
      for (int i = 0; i < n; i++)
        if (ar[i] != -1 and ar[i] <= cnt) {
          ar[i] = -1;
          cnt++;
        }
    } else {
      for (int i = n - 1; i >= 0; i--)
        if (ar[i] != -1 and ar[i] <= cnt) {
          ar[i] = -1;
          cnt++;
        }
    }
    if (cnt == n) {
      printf("%d\n", mov - 1);
      return 0;
    }
  }
}
