#include <bits/stdc++.h>
using namespace std;
int n;
int a[2000];
bool vis[2000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  int dir = 0;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    bool ok = 0;
    if (dir == 0) {
      for (int j = 0; j < n; j++) {
        if (!vis[j] && a[j] <= cur)
          cur++, vis[j] = 1;
        else if (!vis[j])
          ok = 1;
      }
    } else {
      for (int j = n - 1; j >= 0; j--) {
        if (!vis[j] && a[j] <= cur)
          cur++, vis[j] = 1;
        else if (!vis[j])
          ok = 1;
      }
    }
    if (!ok) break;
    ans++;
    dir = !dir;
  }
  cout << ans << "\n";
  return 0;
}
