#include <bits/stdc++.h>
const int maxn = 1e5 + 5, lim = 62, maxm = 65;
const long long inf = 1e18;
template <typename T>
inline T min(T a, T b) {
  return a < b ? a : b;
}
int n;
long long a[maxn], mod, dp[maxm][maxn];
inline bool Comp(long long a, long long b) { return a > b; }
void radix_sort() {
  std::vector<long long> bit[2];
  for (int i = 1; i <= n; i++) {
    bit[(a[i] & (1ll << (mod - 1))) > 0ll].push_back(a[i]);
  }
  int cnt = 0;
  for (int i = 0; i < bit[1].size(); i++) a[++cnt] = bit[1][i];
  for (int i = 0; i < bit[0].size(); i++) a[++cnt] = bit[0][i];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  std::sort(a + 1, a + n + 1, Comp);
  for (int i = n; i >= 1; i--) a[i] = a[1] - a[i];
  for (int i = 0; i <= lim; i++)
    for (int j = 0; j <= n; j++) dp[i][j] = inf;
  dp[0][0] = 0;
  for (int i = 0; i < lim; i++) {
    mod = i;
    if (i) radix_sort();
    long long cnt = 0, tot = 0;
    mod = 1ll << i;
    for (int j = 1; j <= n; j++) cnt += a[j] & mod ? 1 : 0;
    for (int j = 0; j <= n; j++) {
      tot += a[j] & mod ? 1 : 0;
      dp[i + 1][cnt - tot + j] =
          min(dp[i + 1][cnt - tot + j], dp[i][j] + tot + (n - j) - (cnt - tot));
      dp[i + 1][tot] = min(dp[i + 1][tot], dp[i][j] + j - tot + cnt - tot);
    }
  }
  printf("%lld\n", dp[lim][0]);
  return 0;
}
