#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  int n;
  scanf("%d", &n);
  ;
  int a[n];
  int vis[n];
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  ;
  int c = 0;
  int d = 0;
  int si = 0;
  int res = 0;
  while (c != n) {
    for (int i = 0; i < n; i++) {
      if (vis[i] == 0 && a[i] <= res) {
        res++;
        vis[i] = 1;
        c++;
      }
    }
    if (c == n) break;
    d++;
    for (int i = n - 1; i >= 0; i--) {
      if (vis[i] == 0 && a[i] <= res) {
        res++;
        vis[i] = 1;
        c++;
      }
    }
    if (c == n) break;
    d++;
  }
  cout << d << "\n";
  return 0;
}
