// Arup Guha
// 11/17/2014
// Solution to 2014 Southeast Regional D1 and D2 Problem: Shuffles

import java.util.*;
import java.io.*;

public class shuffles {

	public static void main(String[] args) throws Exception {

		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(stdin.readLine());
		StringTokenizer tok = new StringTokenizer(stdin.readLine());

		// Count number of inversions of terms of form (i, i+1).
		boolean[] used = new boolean[n];
		int consecInvert = 0;
		for (int i=0; i<n; i++) {
			int next = Integer.parseInt(tok.nextToken());
			if (next > 1 && !used[next-2]) consecInvert++;
			used[next-1] = true;
		}

		// When we do k iterations, we can get a max of 2^k-1 of these inversions.
		// Doing slow method, but it's easy and never runs more than 20 times.
		int sum = 0, term = 1, ans = 0;
		while (sum < consecInvert) {
			ans++;
			sum += term;
			term *= 2;
		}

		// Ta da!
		System.out.println(ans);
	}
}