#include <bits/stdc++.h>
using namespace std;
int n, a[2000], cur, ans, last;
bool used[2000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int kol = n;
  for (int i = 0; i < n; i++) {
    if (!used[i] && a[i] <= cur) {
      cur++;
      used[i] = true;
      kol--;
    }
    if (!used[i] && a[i] > cur)
      while (1) {
        for (int j = i + 1; j < n; j++)
          if (!used[j] && a[j] <= cur) {
            cur++;
            used[j] = true;
            last = j;
            kol--;
          }
        ans++;
        for (int j = last; j > i; j--)
          if (!used[j] && a[j] <= cur) {
            cur++;
            used[j] = true;
            kol--;
          }
        if (a[i] <= cur) {
          cur++;
          kol--;
          if (kol != 0) ans++;
          break;
        } else
          ans++;
      }
  }
  printf("%d", ans);
}
