#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10, M = 510, INF = 0x3f3f3f3f, base = 131;
long long a[N], b[N];
bool st[N], stb[N];
signed main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long cnt = 0;
  long long ans = 0;
  while (1) {
    if (ans % 2 == 0)
      for (long long i = 1; i <= n; i++) {
        if (!st[i] && a[i] <= cnt) {
          cnt++;
          st[i] = true;
        }
      }
    else {
      for (long long i = n; i >= 1; i--) {
        if (!st[i] && a[i] <= cnt) {
          cnt++;
          st[i] = true;
        }
      }
    }
    if (cnt == n) break;
    ans++;
  }
  cout << ans;
  return 0;
}
