#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
const long long int INF = 1e15;
const long long int MOD = 1e9 + 7;
long long int rootn(long long int x, long long int y) {
  return ceil(log(x) / log(y));
}
bool sortbysec(pair<long long int, long long int> &a,
               pair<long long int, long long int> &b) {
  return a.second < b.second;
}
bool sortbyfirstdesc(pair<long long int, long long int> &a,
                     pair<long long int, long long int> &b) {
  return a.first > b.first;
}
bool sortbysecdesc(pair<long long int, long long int> &a,
                   pair<long long int, long long int> &b) {
  return a.second > b.second;
}
long long int power(long long int x, long long int y) {
  if (y == 0) return 1;
  if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
long long int inversemod(long long int n, long long int mod) {
  return power(n, mod - 2) % MOD;
}
const long long int maxl = 2e5 + 5;
bool isprime[maxl];
long long int fact[maxl];
void sieve() {
  memset(isprime, true, sizeof(isprime));
  isprime[0] = isprime[1] = false;
  for (long long int i = 2; i * i < maxl; i++) {
    if (isprime[i]) {
      for (long long int j = i * i; j < maxl; j += i) isprime[j] = false;
    }
  }
}
void inifact() {
  fact[0] = 1;
  fact[1] = 1;
  for (long long int i = 2; i < maxl; i++) {
    fact[i] = i * fact[i - 1];
    fact[i] %= MOD;
  }
}
long long int dfs(vector<long long int> v, long long int idx) {
  if (v.size() == 1) return 0;
  long long int x = 1 << idx;
  vector<long long int> v1, v2;
  for (long long int i = 0; i < v.size(); i++) {
    long long int k = x & v[i];
    if (k >= x) {
      v2.push_back(v[i]);
    } else {
      v1.push_back(v[i]);
    }
  }
  if (v1.size() == 0) {
    return dfs(v2, idx - 1);
  } else if (v2.size() == 0)
    return dfs(v1, idx - 1);
  else {
    return 1 + max(dfs(v1, idx - 1), dfs(v2, idx - 1));
  }
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << n - 1 - dfs(a, 30) << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long int t = 1;
  while (t--) solve();
}

### Prompt

Your challenge is to write a Cpp solution to 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;
const double pi = 3.14159265358979323846;
const long long int INF = 1e15;
const long long int MOD = 1e9 + 7;
long long int rootn(long long int x, long long int y) {
  return ceil(log(x) / log(y));
}
bool sortbysec(pair<long long int, long long int> &a,
               pair<long long int, long long int> &b) {
  return a.second < b.second;
}
bool sortbyfirstdesc(pair<long long int, long long int> &a,
                     pair<long long int, long long int> &b) {
  return a.first > b.first;
}
bool sortbysecdesc(pair<long long int, long long int> &a,
                   pair<long long int, long long int> &b) {
  return a.second > b.second;
}
long long int power(long long int x, long long int y) {
  if (y == 0) return 1;
  if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
long long int inversemod(long long int n, long long int mod) {
  return power(n, mod - 2) % MOD;
}
const long long int maxl = 2e5 + 5;
bool isprime[maxl];
long long int fact[maxl];
void sieve() {
  memset(isprime, true, sizeof(isprime));
  isprime[0] = isprime[1] = false;
  for (long long int i = 2; i * i < maxl; i++) {
    if (isprime[i]) {
      for (long long int j = i * i; j < maxl; j += i) isprime[j] = false;
    }
  }
}
void inifact() {
  fact[0] = 1;
  fact[1] = 1;
  for (long long int i = 2; i < maxl; i++) {
    fact[i] = i * fact[i - 1];
    fact[i] %= MOD;
  }
}
long long int dfs(vector<long long int> v, long long int idx) {
  if (v.size() == 1) return 0;
  long long int x = 1 << idx;
  vector<long long int> v1, v2;
  for (long long int i = 0; i < v.size(); i++) {
    long long int k = x & v[i];
    if (k >= x) {
      v2.push_back(v[i]);
    } else {
      v1.push_back(v[i]);
    }
  }
  if (v1.size() == 0) {
    return dfs(v2, idx - 1);
  } else if (v2.size() == 0)
    return dfs(v1, idx - 1);
  else {
    return 1 + max(dfs(v1, idx - 1), dfs(v2, idx - 1));
  }
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << n - 1 - dfs(a, 30) << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long int t = 1;
  while (t--) solve();
}

```