#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  int ans = -1, now = 0;
  vector<bool> vis(n);
  while (now < n) {
    ans++;
    if (ans % 2)
      for (int i = n - 1; i >= 0; i--)
        if (!vis[i] && a[i] <= now)
          vis[i] = true, now++;
        else
          ;
    else
      for (int i = 0; i < n; i++)
        if (!vis[i] && a[i] <= now)
          vis[i] = true, now++;
        else
          ;
  }
  cout << ans << '\n';
  return 0;
}
