#include <bits/stdc++.h>
using namespace std;
int n;
long long c[200005];
int b[200005];
int a[100005];
void up(int n, int k) {
  if (!n) return;
  while (n <= 200000) {
    b[n]++;
    c[n] += k;
    k++;
    n <<= 1;
  }
}
void solve(int n) {
  int cur = 0;
  long long num = n * 2;
  up(num, 1);
  num = n;
  cur = 0;
  while (num) {
    if (num & 1) {
      up(num / 2 * 2, cur + 2);
    }
    b[num]++;
    c[num] += cur;
    num >>= 1;
    cur++;
  }
}
int main() {
  scanf("%d", &n);
  memset(c, 0, sizeof(c));
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    solve(a[i]);
  }
  long long res = 1000000000;
  for (int i = 0; i <= 200000; i++) {
    if (b[i] == n) {
      res = min(res, c[i]);
    }
  }
  printf("%lld\n", res);
}
