#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, id[N], f[61][N], num[2], tmp[N];
long long a[N], mx;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (mx < a[i]) mx = a[i];
  }
  for (int i = 1; i <= n; i++) a[i] = mx - a[i], id[i] = i;
  memset(f, 0x3f3f3f3f, sizeof(f)), f[0][0] = 0;
  for (int i = 0; i < 60; i++) {
    num[0] = num[1] = 0;
    for (int j = 1; j <= n; j++) ++num[(a[j] >> i) & 1ll];
    int w = num[1], Now = 0;
    for (int j = 0; j <= n; j++) {
      f[i + 1][Now] = min(f[i + 1][Now], f[i][j] + w);
      f[i + 1][Now + w] = min(f[i + 1][Now + w], f[i][j] + n - w);
      if ((a[id[j + 1]] >> i) & 1ll)
        ++Now, --w;
      else
        ++w;
    }
    num[0] += num[1];
    for (int j = n; j; j--) tmp[num[(a[id[j]] >> i) & 1ll]--] = id[j];
    swap(id, tmp);
  }
  printf("%d\n", f[59][0]);
  return 0;
}
