#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
long long gcd(long long a, long long b) {
  if ((a == 0) || (b == 0)) return a + b;
  return gcd(b, a % b);
}
long long pow_mod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return res;
}
long long arr[1010], res, arr2[1010];
vector<pair<int, int> > vc;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long N, i, j, X, Y;
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> arr[i];
    vc.push_back(make_pair(arr[i], i));
  }
  long long ans2 = 0, opp = 0;
  while (1) {
    for (i = 0; i <= N - 1; i++) {
      if ((vc[i].first <= ans2) && (!arr2[vc[i].second])) {
        arr2[vc[i].second] = 1;
        ans2++;
      }
    }
    opp++;
    if (ans2 != N) {
      res++;
      for (i = N - 1; i >= 0; i--) {
        if ((vc[i].first <= ans2) && (!arr2[vc[i].second])) {
          arr2[vc[i].second] = 1;
          ans2++;
        }
      }
    }
    opp++;
    if (ans2 == N) {
      break;
    } else {
      res++;
    }
  }
  cout << res;
  return 0;
}
