#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int num[maxn];
int sum[maxn];
void work(int tmp, int cnt) {
  for (tmp = tmp << 1, cnt++; tmp < maxn; tmp = tmp << 1, cnt++) {
    num[tmp]++;
    sum[tmp] += cnt;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int i, a;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    bool flag = true;
    int cnt = 0;
    while (a) {
      num[a]++;
      sum[a] += cnt;
      if (flag) work(a, cnt);
      if (a & 1)
        flag = true;
      else
        flag = false;
      a = a >> 1;
      cnt++;
    }
  }
  int ans = 0x3f3f3f3f;
  for (i = 1; i < maxn; i++)
    if (num[i] == n) ans = min(ans, sum[i]);
  cout << ans << endl;
  return 0;
}
