#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x7f7f7f7f;
const long long N = 5000;
long long n, arr[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long sum = 0, ans = 0;
  while (1) {
    for (long long i = 0; i < n; i++)
      if (arr[i] <= sum) {
        arr[i] = n + 1;
        sum++;
      }
    if (sum == n) break;
    ans++;
    for (long long i = n - 1; i >= 0; i--)
      if (arr[i] <= sum) {
        arr[i] = n + 1;
        sum++;
      }
    if (sum == n) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
