#include <bits/stdc++.h>
using namespace std;
vector<int> pcs;
vector<bool> vis;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    pcs.push_back(a);
    vis.push_back(false);
  }
  int maxelm = *max_element(pcs.begin(), pcs.end());
  int doc = 0;
  int turns = 0;
  int start = 0;
  int end = 0;
  while (true) {
    for (int i = start; i < n; ++i) {
      if ((pcs[i] <= doc) && (!vis[i])) {
        doc++;
        vis[i] = true;
        end = i;
      }
    }
    turns++;
    if (doc >= n) {
      turns--;
      break;
    }
    for (int i = end; i >= 0; --i) {
      if ((pcs[i] <= doc) && (!vis[i])) {
        doc++;
        vis[i] = true;
        start = i;
      }
    }
    turns++;
    if (doc >= n) {
      turns--;
      break;
    }
  }
  cout << turns << endl;
  return 0;
}
