#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
int A[MAXN], kq[MAXN] = {0}, cnt[MAXN] = {0}, N;
void x2(int a, int sb) {
  while (a < MAXN) {
    cnt[a]++;
    kq[a] += sb;
    a *= 2;
    sb++;
  }
}
void them(int a) {
  cnt[a]++;
  x2(a * 2, 1);
  int sb = 0;
  while (1) {
    if (a == 1) break;
    sb++;
    if (a & 1) x2((a / 2) * 2, sb + 1);
    a /= 2;
    cnt[a]++;
    kq[a] += sb;
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
  for (int i = 1; i <= N; i++) {
    them(A[i]);
  }
  int res = 2e9;
  for (int i = 1; i < MAXN; i++)
    if (cnt[i] == N) res = min(res, kq[i]);
  printf("%d\n", res);
  return 0;
}
