#include <bits/stdc++.h>
using namespace std;
int d[2][(long long)1e5 + 1];
struct comp {
  int nr;
  comp(int nr) : nr(nr) {}
  bool operator()(const long long& a, const long long& b) const {
    long long m = (1LL << (nr + 1)) - 1;
    return (a & m) > (b & m);
  }
};
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> v(n);
  for (auto& e : v) scanf("%lld", &e);
  int mx = 64 * n;
  sort(v.begin(), v.end());
  for (int i = 0; i < n - 1; i++) v[i] = v[n - 1] - v[i];
  v.pop_back();
  n--;
  for (int i = 1; i <= n; i++) d[1][i] = mx;
  d[1][0] = 0;
  int ok = 1;
  for (int j = 0; j < 63; j++, ok = !ok) {
    if (j > 0) {
      sort(v.begin(), v.end(), comp(j - 1));
    }
    int nr1 = 0, nr1c = 0;
    for (int i = 0; i <= n; i++) d[!ok][i] = mx;
    for (int i = 0; i < n; i++) nr1 += v[i] & (1LL << j) ? 1 : 0;
    for (int i = 0; i <= n; i++) {
      if (i > 0) {
        int toadd = v[i - 1] & (1LL << j) ? 1 : 0;
        nr1c += toadd;
        nr1 -= toadd;
      }
      d[!ok][nr1c] = min(d[!ok][nr1c], d[ok][i] + nr1 + (i - nr1c));
      d[!ok][nr1 + i] =
          min(d[!ok][nr1 + i], d[ok][i] + (n - i - nr1) + nr1c + 1);
    }
  }
  printf("%d\n", d[ok][0]);
  return 0;
}
