#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long double pi = 3.14159265358979323846264338327950288419716939937510;
long long po(long long a, long long b) {
  long long res = 1 % mod;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & (1LL)) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const long double eps = 1e-10;
const int oo = 1000000009;
const long long ooo = 2e18 + 5;
const int MAXN = 2e5 + 5;
int n;
int aa[1009];
bool mark[1009];
inline void solve() {}
inline void readInput() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &aa[i]);
    mark[i] = false;
  }
  int cnt = 0;
  int ans = 0;
  bool turn = true;
  while (cnt != n) {
    if (turn) {
      for (int i = 1; i <= n; i++) {
        if (mark[i]) continue;
        if (aa[i] <= cnt) {
          mark[i] = true;
          cnt++;
        }
      }
    } else {
      for (int i = n; i >= 1; i--) {
        if (mark[i]) continue;
        if (aa[i] <= cnt) {
          mark[i] = true;
          cnt++;
        }
      }
    }
    if (cnt == n) break;
    ans++;
    turn = !turn;
  }
  cout << ans;
}
inline void preProcess() {}
int main() {
  preProcess();
  readInput();
  return 0;
}
