#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void remin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void remax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
long long vis[1005];
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long cur = 0;
  long long ans = 0;
  long long cnt = 0;
  while (cnt != n) {
    if (cur == 0) {
      for (long long i = 0; i < n; i++) {
        if (a[i] <= cnt && !vis[i]) {
          cnt++;
          vis[i] = 1;
        }
      }
      cur = n - 1;
    } else {
      for (long long i = n - 1; i >= 0; i--) {
        if (a[i] <= cnt && !vis[i]) {
          cnt++;
          vis[i] = 1;
        }
      }
      cur = 0;
    }
    ans++;
  }
  cout << ans - 1 << "\n";
  ;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
