#include <bits/stdc++.h>
using namespace std;
int a[1005], n, mrk[1005];
int findfirst(int pos, int val) {
  for (int i = pos + 1; i < n; i++) {
    if (a[i] <= val && !mrk[i]) return i;
  }
  return -1;
}
int findback(int pos, int val) {
  for (int i = pos - 1; i >= 0; i--) {
    if (a[i] <= val && !mrk[i]) return i;
  }
  return -1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  int curr = 0;
  int dir = 1;
  int i = 0;
  if (a[0] <= cnt) {
    i++;
    mrk[0] = 1;
    cnt++;
  }
  int ans = 0;
  while (i < n) {
    if (dir == 1) {
      int k = findfirst(curr, cnt);
      if (k != -1) {
        curr = k;
        mrk[k] = 1;
        cnt++;
      } else {
        ans++;
        k = findback(curr, cnt);
        curr = k;
        mrk[k] = 1;
        cnt++;
        dir = -1;
      }
    } else {
      int k = findback(curr, cnt);
      if (k != -1) {
        curr = k;
        mrk[k] = 1;
        cnt++;
      } else {
        ans++;
        k = findfirst(curr, cnt);
        mrk[k] = 1;
        curr = k;
        cnt++;
        dir = 1;
      }
    }
    i++;
  }
  cout << ans;
}
