#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
int n, m;
int a[2000];
int b[2000];
int vis[2000];
int main() {
  int i, j;
  cin >> n;
  int cnt = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) b[cnt++] = i;
  }
  int ans = INF;
  fill(vis, vis + 2000, 0);
  int num = 0;
  int dir = 0;
  int now = b[0];
  int ans1 = 0;
  while (num < n) {
    int tem = num;
    if (dir == 0) {
      for (i = now; i < n; i++) {
        if (!vis[i] && num >= a[i]) {
          vis[i] = 1;
          num++;
          m = i;
        }
      }
      if (tem == num) break;
      now = m;
    } else {
      for (i = now; i >= 0; i--) {
        if (!vis[i] && num >= a[i]) {
          vis[i] = 1;
          num++;
          m = i;
        }
      }
      if (tem == num) break;
      now = m;
    }
    dir = (dir + 1) % 2;
    if (num == n) break;
    ans1++;
  }
  ans = min(ans, ans1);
  printf("%d\n", ans);
  return 0;
}
