#include <bits/stdc++.h>
int a[1005], v[1005];
int main() {
  int n;
  memset(v, 0, sizeof(v));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int x = 0, cnt = 0, i = 0, t = 0;
  while (1) {
    if (i == 0 || i == (n - 1)) t++;
    if (t % 2) {
      if (a[i] <= cnt && v[i] == 0) {
        cnt++;
        v[i] = 1;
        x++;
        if (x == n) break;
        i++;
      } else
        i++;
    } else {
      if (a[i] <= cnt && v[i] == 0) {
        cnt++;
        v[i] = 1;
        x++;
        if (x == n) break;
        i--;
      } else
        i--;
    }
  }
  if (n == 1)
    printf("0\n");
  else {
    if (i == 0 || i == (n - 1)) t--;
    printf("%d\n", t - 1);
  }
  return 0;
}
