Xor Tree

题意翻译

给定你一个非负整数序列 $a$,保证其中每个数两两不同。 对于每个 $a _ i$,它会向 $j \ne i$ 且 $a_i\oplus a_j$($\oplus$ 代表异或)最小的 $a _ j$ 连双向边。 如果 $a _ j$ 也向 $a _ i$ 连了边,只算一条边。现在要让你删去序列中的一些数,使得最后形成的图是一颗树,输出最少需要删除几个数。 Translated by [试试事实上吗](https://www.luogu.com.cn/user/199750).

题目描述

For a given sequence of distinct non-negative integers $ (b_1, b_2, \dots, b_k) $ we determine if it is good in the following way: - Consider a graph on $ k $ nodes, with numbers from $ b_1 $ to $ b_k $ written on them. - For every $ i $ from $ 1 $ to $ k $ : find such $ j $ ( $ 1 \le j \le k $ , $ j\neq i $ ), for which $ (b_i \oplus b_j) $ is the smallest among all such $ j $ , where $ \oplus $ denotes the operation of bitwise XOR ([https://en.wikipedia.org/wiki/Bitwise\_operation#XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR)). Next, draw an undirected edge between vertices with numbers $ b_i $ and $ b_j $ in this graph. - We say that the sequence is good if and only if the resulting graph forms a tree (is connected and doesn't have any simple cycles). It is possible that for some numbers $ b_i $ and $ b_j $ , you will try to add the edge between them twice. Nevertheless, you will add this edge only once. You can find an example below (the picture corresponding to the first test case). Sequence $ (0, 1, 5, 2, 6) $ is not good as we cannot reach $ 1 $ from $ 5 $ . However, sequence $ (0, 1, 5, 2) $ is good. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1446C/787661480e10ca394e5bb0097a1db13aac775e6e.png)You are given a sequence $ (a_1, a_2, \dots, a_n) $ of distinct non-negative integers. You would like to remove some of the elements (possibly none) to make the remaining sequence good. What is the minimum possible number of removals required to achieve this goal? It can be shown that for any sequence, we can remove some number of elements, leaving at least $ 2 $ , so that the remaining sequence is good.

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 2 \le n \le 200,000 $ ) — length of the sequence. The second line contains $ n $ distinct non-negative integers $ a_1, a_2, \ldots, a_n $ ( $ 0 \le a_i \le 10^9 $ ) — the elements of the sequence.

输出格式


You should output exactly one integer — the minimum possible number of elements to remove in order to make the remaining sequence good.

输入输出样例

输入样例 #1

5
0 1 5 2 6

输出样例 #1

1

输入样例 #2

7
6 9 8 7 3 5 2

输出样例 #2

2

说明

Note that numbers which you remove don't impact the procedure of telling whether the resulting sequence is good. It is possible that for some numbers $ b_i $ and $ b_j $ , you will try to add the edge between them twice. Nevertheless, you will add this edge only once.