#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;
template <typename T>
void ckmin(T &a, const T &b) {
  a = min(a, b);
}
template <typename T>
void ckmax(T &a, const T &b) {
  a = max(a, b);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace __input {
template <class T1, class T2>
void re(pair<T1, T2> &p);
template <class T>
void re(vector<T> &a);
template <class T, size_t SZ>
void re(array<T, SZ> &a);
template <class T>
void re(T &x) {
  cin >> x;
}
void re(double &x) {
  string t;
  re(t);
  x = stod(t);
}
template <class Arg, class... Args>
void re(Arg &first, Args &...rest) {
  re(first);
  re(rest...);
}
template <class T1, class T2>
void re(pair<T1, T2> &p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T> &a) {
  for (int i = 0; i < (int((a).size())); i++) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ> &a) {
  for (int i = 0; i < (SZ); i++) re(a[i]);
}
}  // namespace __input
using namespace __input;
namespace __output {
template <
    class T, typename V = decltype(declval<const T &>().begin()),
    typename S = typename enable_if<!is_same<T, string>::value, bool>::type>
void pr(const T &x);
template <class T,
          typename V = decltype(declval<ostream &>() << declval<const T &>())>
void pr(const T &x) {
  cout << x;
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x);
template <class Arg, class... Args>
void pr(const Arg &first, const Args &...rest) {
  pr(first);
  pr(rest...);
}
template <class T, bool pretty = true>
void prContain(const T &x) {
  if (pretty) pr("{");
  bool fst = 1;
  for (const auto &a : x) pr(!fst ? pretty ? ", " : " " : "", a), fst = 0;
  if (pretty) pr("}");
}
template <class T>
void pc(const T &x) {
  prContain<T, false>(x);
  pr("\n");
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T, typename V, typename S>
void pr(const T &x) {
  prContain(x);
}
void ps() { pr("\n"); }
template <class Arg>
void ps(const Arg &first) {
  pr(first);
  ps();
}
template <class Arg, class... Args>
void ps(const Arg &first, const Args &...rest) {
  pr(first, " ");
  ps(rest...);
}
}  // namespace __output
using namespace __output;
namespace __algorithm {
template <typename T>
void dedup(vector<T> &v) {
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
}
template <typename T>
typename vector<T>::const_iterator find(const vector<T> &v, const T &x) {
  auto it = lower_bound((v).begin(), (v).end(), x);
  return it != v.end() && *it == x ? it : v.end();
}
template <typename T>
size_t index(const vector<T> &v, const T &x) {
  auto it = find(v, x);
  assert(it != v.end() && *it == x);
  return it - v.begin();
}
template <typename T1, typename T2>
typename vector<pair<T1, T2>>::iterator lower_bound(
    const vector<pair<T1, T2>> &v, const T1 &x) {
  return lower_bound(
      (v).begin(), (v).end(), x,
      [](pair<T1, T2> a, pair<T1, T2> b) { return a.first < b.first; });
}
template <typename T1, typename T2>
typename vector<pair<T1, T2>>::iterator upper_bound(
    const vector<pair<T1, T2>> &v, const T1 &x) {
  return upper_bound(
      (v).begin(), (v).end(), x,
      [](pair<T1, T2> a, pair<T1, T2> b) { return a.first < b.first; });
}
}  // namespace __algorithm
using namespace __algorithm;
struct __monostate {
  friend istream &operator>>(istream &is,
                             const __attribute__((unused)) __monostate &ms) {
    return is;
  }
  friend ostream &operator<<(ostream &os,
                             const __attribute__((unused)) __monostate &ms) {
    return os;
  }
} ms;
namespace __io {
void setIn(string second) { freopen(second.c_str(), "r", stdin); }
void setOut(string second) { freopen(second.c_str(), "w", stdout); }
void setIO(string second = "") {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(15);
  if (int((second).size())) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
}  // namespace __io
using namespace __io;
int msb(int x) {
  if (x == 0) return 0;
  return 1 << (31 - __builtin_clz(x));
}
template <typename I>
int first(I begin, I end) {
  vi a;
  for (auto i = begin; i != end; i++) a.push_back(*i);
  ;
  const int n = int((a).size());
  if (n == 1) return 0;
  bool same = true;
  for (int i = 0; i + 1 < n; i++) {
    same &= msb(a[i]) == msb(a[i + 1]);
  }
  if (same) {
    int m = msb(a[0]);
    for (int i = 0; i < n; i++) {
      a[i] ^= m;
    }
    return first(a.begin(), a.end());
  }
  int ans = 1e9;
  int count = 0;
  for (int i = 0, j = 0; i < n; i = j) {
    while (j < n && msb(a[i]) == msb(a[j])) j++;
    int bef = max(count - 1, 0);
    int reg = (j - i) - 1;
    int los = first(a.begin() + i, a.begin() + j);
    ckmin(ans, bef - reg + los);
    count++;
  }
  int nec = n - count;
  ans += nec;
  return ans;
}
int main() {
  setIO();
  int n;
  re(n);
  vi a(n);
  re(a);
  sort((a).begin(), (a).end());
  int ans = first((a).begin(), (a).end());
  ps(ans);
  return 0;
}

### Prompt

Your task is to create 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;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;
template <typename T>
void ckmin(T &a, const T &b) {
  a = min(a, b);
}
template <typename T>
void ckmax(T &a, const T &b) {
  a = max(a, b);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace __input {
template <class T1, class T2>
void re(pair<T1, T2> &p);
template <class T>
void re(vector<T> &a);
template <class T, size_t SZ>
void re(array<T, SZ> &a);
template <class T>
void re(T &x) {
  cin >> x;
}
void re(double &x) {
  string t;
  re(t);
  x = stod(t);
}
template <class Arg, class... Args>
void re(Arg &first, Args &...rest) {
  re(first);
  re(rest...);
}
template <class T1, class T2>
void re(pair<T1, T2> &p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T> &a) {
  for (int i = 0; i < (int((a).size())); i++) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ> &a) {
  for (int i = 0; i < (SZ); i++) re(a[i]);
}
}  // namespace __input
using namespace __input;
namespace __output {
template <
    class T, typename V = decltype(declval<const T &>().begin()),
    typename S = typename enable_if<!is_same<T, string>::value, bool>::type>
void pr(const T &x);
template <class T,
          typename V = decltype(declval<ostream &>() << declval<const T &>())>
void pr(const T &x) {
  cout << x;
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x);
template <class Arg, class... Args>
void pr(const Arg &first, const Args &...rest) {
  pr(first);
  pr(rest...);
}
template <class T, bool pretty = true>
void prContain(const T &x) {
  if (pretty) pr("{");
  bool fst = 1;
  for (const auto &a : x) pr(!fst ? pretty ? ", " : " " : "", a), fst = 0;
  if (pretty) pr("}");
}
template <class T>
void pc(const T &x) {
  prContain<T, false>(x);
  pr("\n");
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T, typename V, typename S>
void pr(const T &x) {
  prContain(x);
}
void ps() { pr("\n"); }
template <class Arg>
void ps(const Arg &first) {
  pr(first);
  ps();
}
template <class Arg, class... Args>
void ps(const Arg &first, const Args &...rest) {
  pr(first, " ");
  ps(rest...);
}
}  // namespace __output
using namespace __output;
namespace __algorithm {
template <typename T>
void dedup(vector<T> &v) {
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
}
template <typename T>
typename vector<T>::const_iterator find(const vector<T> &v, const T &x) {
  auto it = lower_bound((v).begin(), (v).end(), x);
  return it != v.end() && *it == x ? it : v.end();
}
template <typename T>
size_t index(const vector<T> &v, const T &x) {
  auto it = find(v, x);
  assert(it != v.end() && *it == x);
  return it - v.begin();
}
template <typename T1, typename T2>
typename vector<pair<T1, T2>>::iterator lower_bound(
    const vector<pair<T1, T2>> &v, const T1 &x) {
  return lower_bound(
      (v).begin(), (v).end(), x,
      [](pair<T1, T2> a, pair<T1, T2> b) { return a.first < b.first; });
}
template <typename T1, typename T2>
typename vector<pair<T1, T2>>::iterator upper_bound(
    const vector<pair<T1, T2>> &v, const T1 &x) {
  return upper_bound(
      (v).begin(), (v).end(), x,
      [](pair<T1, T2> a, pair<T1, T2> b) { return a.first < b.first; });
}
}  // namespace __algorithm
using namespace __algorithm;
struct __monostate {
  friend istream &operator>>(istream &is,
                             const __attribute__((unused)) __monostate &ms) {
    return is;
  }
  friend ostream &operator<<(ostream &os,
                             const __attribute__((unused)) __monostate &ms) {
    return os;
  }
} ms;
namespace __io {
void setIn(string second) { freopen(second.c_str(), "r", stdin); }
void setOut(string second) { freopen(second.c_str(), "w", stdout); }
void setIO(string second = "") {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(15);
  if (int((second).size())) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
}  // namespace __io
using namespace __io;
int msb(int x) {
  if (x == 0) return 0;
  return 1 << (31 - __builtin_clz(x));
}
template <typename I>
int first(I begin, I end) {
  vi a;
  for (auto i = begin; i != end; i++) a.push_back(*i);
  ;
  const int n = int((a).size());
  if (n == 1) return 0;
  bool same = true;
  for (int i = 0; i + 1 < n; i++) {
    same &= msb(a[i]) == msb(a[i + 1]);
  }
  if (same) {
    int m = msb(a[0]);
    for (int i = 0; i < n; i++) {
      a[i] ^= m;
    }
    return first(a.begin(), a.end());
  }
  int ans = 1e9;
  int count = 0;
  for (int i = 0, j = 0; i < n; i = j) {
    while (j < n && msb(a[i]) == msb(a[j])) j++;
    int bef = max(count - 1, 0);
    int reg = (j - i) - 1;
    int los = first(a.begin() + i, a.begin() + j);
    ckmin(ans, bef - reg + los);
    count++;
  }
  int nec = n - count;
  ans += nec;
  return ans;
}
int main() {
  setIO();
  int n;
  re(n);
  vi a(n);
  re(a);
  sort((a).begin(), (a).end());
  int ans = first((a).begin(), (a).end());
  ps(ans);
  return 0;
}

```