#include <bits/stdc++.h>
using namespace std;
long long a[200010];
long long vis[200010];
long long cnt[200010];
long long n;
long long max_n = 0;
void solve(long long pos) {
  vis[pos]++;
  long long temp1 = pos;
  long long temp2 = pos;
  long long step1 = 0;
  long long step2 = 0;
  while (temp1 <= max_n) {
    temp1 <<= 1;
    step1++;
    vis[temp1]++;
    cnt[temp1] += step1;
  }
  while (temp2) {
    if ((temp2 & 1) && (temp2 != 1)) {
      temp2 >>= 1;
      step2++;
      vis[temp2]++;
      cnt[temp2] += step2;
      long long temp3 = temp2;
      long long step3 = step2;
      while (temp3 <= max_n) {
        temp3 <<= 1;
        step3++;
        vis[temp3]++;
        cnt[temp3] += step3;
      }
    } else {
      temp2 >>= 1;
      step2++;
      vis[temp2]++;
      cnt[temp2] += step2;
    }
  }
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    max_n = max(a[i], max_n);
  }
  memset(vis, 0, sizeof(vis));
  memset(cnt, 0, sizeof(cnt));
  for (long long i = 1; i <= n; i++) solve(a[i]);
  long long ans = 1 << 29;
  for (long long i = 1; i <= 2 * max_n - 1; i++) {
    if (vis[i] == n) ans = min(ans, cnt[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
