#include <iostream>
#include <vector>
using namespace std;

int main() 
{
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
		
	int res = 0;
	
	int has = 0;
	while (true)
	{
		for (int i = 0; i < n; ++i)
			if (a[i] <= has)
			{
				++has;
				a[i] = 2000;
			}
		
		if (has == n)
			break;
			
		++res;
		
		for (int i = n - 1; i >= 0; --i)
			if (a[i] <= has)
			{
				++has;
				a[i] = 2000;
			}
		
		if (has == n)
			break;
			
		++res;
	}
	
	cout << res;
	
	return 0;
}