#include <bits/stdc++.h>
using namespace std;
int v[101010];
int vy[1010];
int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> v[i];
  }
  int num = 0;
  int ret = -1;
  for (int i = 1; i <= N; ++i) {
    ++ret;
    for (int j = 1; j <= N; ++j) {
      int rj = j;
      if (i % 2 == 0) {
        rj = N - j + 1;
      }
      if (v[rj] <= num) {
        ++num;
        v[rj] = 101010;
      }
    }
    if (num == N) {
      break;
    }
  }
  cout << ret;
}
