#include <bits/stdc++.h>
const int N = 1000 + 5;
int n, now = 0, res = 0, a[N], bo[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  while (now < n) {
    ++res;
    if (res & 1) {
      for (int i = 0; i < n; ++i)
        if (!bo[i] && now >= a[i]) bo[i] = 1, ++now;
    } else {
      for (int i = n - 1; ~i; --i)
        if (!bo[i] && now >= a[i]) bo[i] = 1, ++now;
    }
  }
  printf("%d\n", res - 1);
  return 0;
}
