#include <bits/stdc++.h>
using namespace std;
long long A[100005];
int n, w, f[62][100005], idx[100005], sum[2][100005];
bool cmp(int a, int b) {
  return (A[a] & ((1ll << w) - 1)) < (A[b] & ((1ll << w) - 1));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &A[i]);
  sort(A + 1, A + n + 1);
  for (int i = 1; i <= n; i++) A[i] = A[n] - A[i], idx[i] = i;
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int k = 0; k <= 60; k++) {
    w = k;
    sort(idx + 1, idx + n + 1, cmp);
    for (int i = 1; i <= n; i++) {
      sum[0][i] = sum[0][i - 1];
      sum[1][i] = sum[1][i - 1];
      sum[(A[idx[i]] >> k) & 1][i]++;
    }
    for (int i = 0; i <= n; i++) {
      int w, x;
      w = sum[1][n - i] + sum[0][n] - sum[0][n - i];
      x = sum[1][n] - sum[1][n - i];
      f[k + 1][x] = min(f[k + 1][x], f[k][i] + w);
      w = sum[0][n - i] + sum[1][n] - sum[1][n - i];
      x = n - sum[0][n - i];
      f[k + 1][x] = min(f[k + 1][x], f[k][i] + w);
    }
  }
  printf("%d\n", f[61][0]);
}
