#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 1;
const int nol = 0;
long long n, a, cnt, ans, sum;
deque<long long> v;
void vkoshp() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  while (v.size()) {
    for (long long i = 0; i < v.size(); i++) {
      if (cnt >= v[i]) {
        cnt++;
        v.erase(v.begin() + i);
        i--;
      }
    }
    if (v.size() == 0) break;
    ans++;
    reverse(v.begin(), v.end());
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) vkoshp();
}
