#include <bits/stdc++.h>
using namespace std;
long long a[2000];
bool b[2000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long m = 0, ans = -1;
  while (m < n) {
    ans++;
    for (int i = 0; i < n; i++)
      if (a[i] <= m && !b[i]) {
        b[i] = true;
        m++;
      }
    if (m == n) break;
    ans++;
    for (int i = n - 1; i >= 0; i--)
      if (a[i] <= m && !b[i]) {
        b[i] = true;
        m++;
      }
  }
  cout << ans << endl;
  return 0;
}
