#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
constexpr int INF = 1000000000;
constexpr long long llINF = 1000000000000000000;
constexpr int mod = 1000000007;
constexpr double eps = 1e-8;
const double pi = acos(-1);
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int Random(int mi, int ma) {
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<int> engine(mi, ma);
  return engine(mt);
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool prime(int a) {
  if (a == 1) return false;
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) return false;
  }
  return true;
}
long long modpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) return modpow(a, b - 1) * a % mod;
  long long memo = modpow(a, b / 2);
  return memo * memo % mod;
}
vector<long long> kaijo, invkaijo;
void init_fact(int n) {
  kaijo.resize(n + 1);
  invkaijo.resize(n + 1);
  kaijo[0] = 1;
  for (long long i = 1; i <= n; i++) {
    kaijo[i] = kaijo[i - 1] * i;
    kaijo[i] %= mod;
  }
  for (int i = 0; i < n + 1; i++) invkaijo[i] = modpow(kaijo[i], mod - 2);
}
long long comb(int a, int b) {
  if (a < b) return 0;
  if (a < 0) return 0;
  return kaijo[a] * invkaijo[a - b] % mod * invkaijo[b] % mod;
}
long long inv(long long x) {
  x = modpow(x, mod - 2);
  return x;
}
int n, a[200010], msb[200010];
int solve(int l, int r) {
  if (r - l == 1) return 1;
  for (int i = r - 2; i >= l; i--) {
    if (msb[i] != msb[i + 1]) {
      int len = i + 1 - l, ren = r - (i + 1);
      if (len >= 2 && ren >= 2) {
        int res1 = solve(l, i + 1) + 1, res2 = solve(i + 1, r) + 1;
        return max(res1, res2);
      }
      if (len >= 2) {
        return solve(l, i + 1) + 1;
      }
      if (ren >= 2) {
        return solve(i + 1, r) + 1;
      }
      return 2;
    }
  }
  int m = msb[l] - 1;
  for (int i = l; i < r; i++) {
    a[i] -= (1 << m);
    if (a[i] == 0)
      msb[i] = 0;
    else {
      for (int j = 29; j >= 0; j--) {
        if ((a[i] >> j) & 1) {
          msb[i] = j + 1;
          break;
        }
      }
    }
  }
  return solve(l, r);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] == 0)
      msb[i] = 0;
    else {
      for (int j = 29; j >= 0; j--) {
        if ((a[i] >> j) & 1) {
          msb[i] = j + 1;
          break;
        }
      }
    }
  }
  cout << n - solve(0, n) << endl;
  return 0;
}

### Prompt

Please formulate 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;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
constexpr int INF = 1000000000;
constexpr long long llINF = 1000000000000000000;
constexpr int mod = 1000000007;
constexpr double eps = 1e-8;
const double pi = acos(-1);
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int Random(int mi, int ma) {
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<int> engine(mi, ma);
  return engine(mt);
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool prime(int a) {
  if (a == 1) return false;
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) return false;
  }
  return true;
}
long long modpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) return modpow(a, b - 1) * a % mod;
  long long memo = modpow(a, b / 2);
  return memo * memo % mod;
}
vector<long long> kaijo, invkaijo;
void init_fact(int n) {
  kaijo.resize(n + 1);
  invkaijo.resize(n + 1);
  kaijo[0] = 1;
  for (long long i = 1; i <= n; i++) {
    kaijo[i] = kaijo[i - 1] * i;
    kaijo[i] %= mod;
  }
  for (int i = 0; i < n + 1; i++) invkaijo[i] = modpow(kaijo[i], mod - 2);
}
long long comb(int a, int b) {
  if (a < b) return 0;
  if (a < 0) return 0;
  return kaijo[a] * invkaijo[a - b] % mod * invkaijo[b] % mod;
}
long long inv(long long x) {
  x = modpow(x, mod - 2);
  return x;
}
int n, a[200010], msb[200010];
int solve(int l, int r) {
  if (r - l == 1) return 1;
  for (int i = r - 2; i >= l; i--) {
    if (msb[i] != msb[i + 1]) {
      int len = i + 1 - l, ren = r - (i + 1);
      if (len >= 2 && ren >= 2) {
        int res1 = solve(l, i + 1) + 1, res2 = solve(i + 1, r) + 1;
        return max(res1, res2);
      }
      if (len >= 2) {
        return solve(l, i + 1) + 1;
      }
      if (ren >= 2) {
        return solve(i + 1, r) + 1;
      }
      return 2;
    }
  }
  int m = msb[l] - 1;
  for (int i = l; i < r; i++) {
    a[i] -= (1 << m);
    if (a[i] == 0)
      msb[i] = 0;
    else {
      for (int j = 29; j >= 0; j--) {
        if ((a[i] >> j) & 1) {
          msb[i] = j + 1;
          break;
        }
      }
    }
  }
  return solve(l, r);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] == 0)
      msb[i] = 0;
    else {
      for (int j = 29; j >= 0; j--) {
        if ((a[i] >> j) & 1) {
          msb[i] = j + 1;
          break;
        }
      }
    }
  }
  cout << n - solve(0, n) << endl;
  return 0;
}

```