#include <bits/stdc++.h>
using namespace std;
int32_t trie[200010 * 32][2], sz[200010 * 32];
long long tam = 1;
long long node() {
  for (long long i = 0; i < 2; i++) trie[tam][i] = 0;
  return tam++;
}
long long v[200010];
void add(long long num, long long id) {
  long long no = 1;
  sz[no]++;
  for (long long i = 31; i >= 0; i--) {
    char c = num >> i & 1;
    if (!trie[no][c]) trie[no][c] = node();
    no = trie[no][c];
    sz[no]++;
  }
}
int32_t f[200010 * 32];
long long dfs(long long no) {
  if (!no) {
    return f[no] = 0;
  }
  long long l = trie[no][0], r = trie[no][1];
  dfs(l);
  dfs(r);
  if (!l)
    f[no] = f[r];
  else if (!r)
    f[no] = f[l];
  else {
    f[no] = min(f[l] + sz[r] - 1, f[r] + sz[l] - 1);
  }
  return f[no];
}
int32_t main() {
  node();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> v[i];
  for (long long i = 0; i < n; i++) {
    add(v[i], i);
  }
  cout << dfs(1) << endl;
  return 0;
}

### Prompt

In CPP, your task is to solve the following problem:

For a given sequence of distinct non-negative integers (b_1, b_2, ..., 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 ≤ j ≤ k, j≠ i), for which (b_i ⊕ b_j) is the smallest among all such j, where ⊕ denotes the operation of bitwise 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. 

<image>

You are given a sequence (a_1, a_2, ..., 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.

Input

The first line contains a single integer n (2 ≤ n ≤ 200,000) — length of the sequence.

The second line contains n distinct non-negative integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the elements of the sequence.

Output

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

Examples

Input


5
0 1 5 2 6


Output


1


Input


7
6 9 8 7 3 5 2


Output


2

Note

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int32_t trie[200010 * 32][2], sz[200010 * 32];
long long tam = 1;
long long node() {
  for (long long i = 0; i < 2; i++) trie[tam][i] = 0;
  return tam++;
}
long long v[200010];
void add(long long num, long long id) {
  long long no = 1;
  sz[no]++;
  for (long long i = 31; i >= 0; i--) {
    char c = num >> i & 1;
    if (!trie[no][c]) trie[no][c] = node();
    no = trie[no][c];
    sz[no]++;
  }
}
int32_t f[200010 * 32];
long long dfs(long long no) {
  if (!no) {
    return f[no] = 0;
  }
  long long l = trie[no][0], r = trie[no][1];
  dfs(l);
  dfs(r);
  if (!l)
    f[no] = f[r];
  else if (!r)
    f[no] = f[l];
  else {
    f[no] = min(f[l] + sz[r] - 1, f[r] + sz[l] - 1);
  }
  return f[no];
}
int32_t main() {
  node();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> v[i];
  for (long long i = 0; i < n; i++) {
    add(v[i], i);
  }
  cout << dfs(1) << endl;
  return 0;
}

```