#include <bits/stdc++.h>
#pragma GCC target("sse4.2")
using namespace std;
bool home = 1;
signed realMain();
signed main() {
  home = 0;
  if (home) {
    freopen("tony_stark", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  realMain();
}
const long long B = 61;
const long long N = (long long)1e5 + 7;
const long long INF = (long long)1e18;
long long n, a[N], dp[B][N];
bool act[N];
long long cnt[3];
signed realMain() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n; i++) {
    a[i] = a[n] - a[i];
  }
  for (long long b = 0; b < B; b++) {
    for (long long i = 0; i < N; i++) {
      dp[b][i] = INF;
    }
  }
  {
    long long ones = 0;
    for (long long i = 1; i <= n; i++) {
      if (a[i] % 2 == 1) {
        ones++;
      }
    }
    dp[0][0] = ones;
    dp[0][ones] = min(dp[0][ones], n - ones);
  }
  for (long long b = 0; b + 1 < B; b++) {
    cnt[0] = cnt[1] = cnt[2] = 0;
    for (long long i = 1; i <= n; i++) {
      act[i] = 0;
    }
    vector<pair<long long, long long>> ks;
    vector<long long> k;
    for (long long i = 1; i <= n; i++) {
      ks.push_back({a[i] % (1LL << (b + 1)), i});
      long long now = !!(a[i] & (1LL << (b + 1)));
      cnt[now]++;
    }
    sort(ks.rbegin(), ks.rend());
    for (auto &it : ks) k.push_back(it.second);
    for (long long pre = 0; pre <= n; pre++) {
      if (pre) {
        long long now = !!(a[k[pre - 1]] & (1LL << (b + 1)));
        cnt[now]--;
        act[k[pre - 1]] = 1;
        cnt[now + 1]++;
      }
      if (dp[b][pre] == INF) continue;
      for (long long put = 0; put <= 1; put++) {
        long long cntt = 0, relax = dp[b][pre];
        for (long long bef = 0; bef <= 2; bef++) {
          long long will_be = (bef + put) % 2;
          long long will_carry = (bef + put) / 2;
          relax += will_be * cnt[bef];
          cntt += will_carry * cnt[bef];
        }
        dp[b + 1][cntt] = min(dp[b + 1][cntt], relax);
      }
    }
  }
  long long ret = dp[B - 1][0];
  cout << ret << "\n";
  return 0;
}
