#include <bits/stdc++.h>
using namespace std;
int n;
int cnt[1000010];
long long dist[1000010];
void go(int num, int d, int p) {
  if (!num || num > 1000000) return;
  cnt[num]++;
  if (p != -1) dist[num] += (d + 1);
  if ((num >> 1) != p) {
    go(num >> 1, d + 1, num);
  }
  if ((num << 1) != p) {
    go(num << 1, d + 1, num);
  }
}
int main() {
  memset(cnt, 0, sizeof(cnt));
  memset(dist, 0, sizeof(dist));
  scanf("%d", &n);
  int ar[n];
  for (int i = 0; i < n; i++) scanf("%d", &ar[i]);
  for (int i = 0; i < n; i++) go(ar[i], -1, -1);
  long long res = 100000000000;
  for (int i = 0; i < 1000010; i++) {
    if (cnt[i] == n) res = min(res, dist[i]);
  }
  printf("%I64d\n", res);
  return 0;
}
