#include <bits/stdc++.h>
int main(void) {
  int n;
  scanf("%d ", &n);
  int a[n], i;
  for (i = 0; i < n; i++) scanf("%d ", &a[i]);
  int count = 0, d = 0;
  while (count != n) {
    i = 0;
    while (i != n) {
      if (a[i] <= count && a[i] != -1) {
        a[i] = -1;
        count++;
      }
      i++;
      if (count == n) break;
    }
    i = n - 2;
    d++;
    if (count == n) break;
    while (i != -1) {
      if (a[i] <= count && a[i] != -1) {
        a[i] = -1;
        count++;
      }
      i--;
    }
    d++;
  }
  printf("%d", d - 1);
  return 0;
}
