1 #include<iostream>
2 #include<algorithm>
3 #include<cstring>
4 #include<cmath>
5 #include<string>
6 using namespace std;
7
8 const int N = 2e5 + 10;
9 int n, a[N];
10
11 int solve(int l, int r, int bit)
12 {
13 if(l > r) return 0;
14 if(bit < 0) return 1;
15 int now = 1 << bit, mid = r + 1;
16
17 for(int i = l ; i <= r ; i++){
18 if(a[i] & now){
19 mid = i;
20 break;
21 }
22 }
23 int x = solve(l, mid - 1, bit - 1), y = solve(mid, r, bit - 1);
24 int ans = max(x + min(1, r - mid + 1), y + min(1, mid - l));//?
25 return ans;
26 }
27
28 int main(){
29 scanf("%d",&n);
30 for(int i = 1 ; i <= n ; i++){
31 scanf("%d",&a[i]);
32 }
33 sort(a + 1, a + n + 1);
34 printf("%d
",n - solve(1, n, 30));
35
36 return 0;
37 }