#include <bits/stdc++.h>
using namespace std;
int n, mn = 1e9;
int a[100005];
int vis[100005];
int tot[100005];
int totcnt[100005];
void solve(int val, int i, int ct) {
  if (vis[val] == i || val < 1 || val > 1e5) return;
  tot[val]++;
  totcnt[val] += ct;
  vis[val] = i;
  solve(val * 2, i, ct + 1);
  solve(val / 2, i, ct + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) solve(a[i], i, 0);
  for (int i = 1; i <= 100000; i++) {
    if (tot[i] == n) mn = min(mn, totcnt[i]);
  }
  printf("%d\n", mn);
  return 0;
}
