#include <bits/stdc++.h>
using namespace std;
long long int a[100000];
int dp[60][100001];
int r;
bool comp(long long int a, long long int b) {
  return (a & ((1LL << r) - 1)) > (b & ((1LL << r) - 1));
}
int main() {
  int i;
  int n;
  long long int m = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%I64d", &a[i]), m = max(m, a[i]);
  for (i = 0; i < n; i++) a[i] = m - a[i];
  int j;
  dp[0][0] = 0;
  for (i = 1; i <= n; i++) dp[0][i] = 1e9;
  for (i = 0; i < 59; i++) {
    r = i;
    sort(a, a + n, comp);
    for (j = 0; j <= n; j++) dp[i + 1][j] = 1e9;
    int c = 0, b = 0;
    for (j = 0; j < n; j++) {
      if (a[j] & (1LL << i)) b++;
    }
    for (j = 0; j <= n; j++) {
      dp[i + 1][c] = min(dp[i + 1][c], dp[i][j] + b + j - 2 * c);
      dp[i + 1][j + b - c] =
          min(dp[i + 1][j + b - c], dp[i][j] + n - (b + j - 2 * c));
      if ((j < n) && (a[j] & (1LL << i))) c++;
    }
  }
  printf("%d\n", dp[59][0]);
  return 0;
}
