// Arup Guha
// 12/11/2025
// Solution to 2025 UCF HS Online D1 Problem C: Solo Leveling

import java.util.*;

public class leveling {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		
		// Root for my trie.
		node trie = new node(false);
		
		// Insert each item.
		for (int i=0; i<n; i++) {
			String tmp = Integer.toBinaryString(stdin.nextInt());
			trie.insert(tmp);
		}
		
		// We traverse each edge twice except longest path to node.
		System.out.println(2*trie.numEdges()-trie.height());
	}
}

class node {

	public boolean isWord;
	public node[] next;
	
	public node(boolean tmp) {
		isWord = tmp;
		next = new node[2];
		Arrays.fill(next, null);
	}
	
	// Inserts s into this trie.
	public void insert(String s) {
	
		// Where I am.
		node cur = this;
		
		// Just go down the trie, creating links as necessary.
		for (int i=0; i<s.length(); i++) {
			if (cur.next[s.charAt(i)-'0'] == null)
				cur.next[s.charAt(i)-'0'] = new node(false);
			cur = cur.next[s.charAt(i)-'0'];
		}
		
		// I probably don't need this...
		cur.isWord = true;
	}
	
	// Returns the height of the trie.
	public int height() {
	
		// Try left and right.
		int left = next[0] == null ? -1 : next[0].height();
		int right = next[1] == null ? -1 : next[1].height();
		
		// This is our answer.
		return Math.max(left+1, right+1);
	}
	
	// Returns the number of links in this trie.
	public int numEdges() {
		int left = next[0] == null ? 0 : next[0].numEdges() + 1;
		int right = next[1] == null ? 0 : next[1].numEdges() + 1;
		return left + right;
	}
}