#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
int main(void) {
  int N;
  cin >> N;
  vector<int> vet(N);
  vector<int> visitado(N);
  vector<int> aux[N];
  for (int i = 0; i < N; ++i) {
    cin >> vet[i];
    aux[vet[i]].push_back(i);
  }
  int p = -1;
  int n = 0;
  int d = 1;
  int make_pair;
  int cont = 0;
  while (n != N) {
    make_pair = d == 1 ? N : -1;
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j < int(aux[i].size()); ++j) {
        if (d == 1 && visitado[aux[i][j]] == 0 && aux[i][j] > p &&
            aux[i][j] < make_pair) {
          make_pair = aux[i][j];
        }
        if (d == -1 && visitado[aux[i][j]] == 0 && aux[i][j] < p &&
            aux[i][j] > make_pair) {
          make_pair = aux[i][j];
        }
      }
    }
    if (make_pair >= 0 && make_pair < N) {
      p = make_pair;
      visitado[p] = 1;
      n++;
    } else {
      d = -d;
      cont++;
    }
  }
  cout << cont << endl;
  return 0;
}
