#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
int n;
int a[N], cnt[2 * N], vis[2 * N];
void deal(int val) {
  int tmp = val, step = 0;
  vis[val]++;
  int tt = tmp, instep = 0;
  while (tt <= (int)1e5) {
    tt <<= 1;
    instep++;
    vis[tt]++;
    cnt[tt] += instep;
  }
  while (tmp) {
    if ((tmp & 1) && tmp != 1) {
      tmp >>= 1;
      step++;
      cnt[tmp] += step;
      vis[tmp]++;
      int tt = tmp;
      int instep = step;
      while (tt <= (int)1e5) {
        tt <<= 1;
        instep++;
        vis[tt]++;
        cnt[tt] += instep;
      }
    } else {
      tmp >>= 1;
      step++;
      cnt[tmp] += step;
      vis[tmp]++;
    }
  }
}
void solve() {
  for (int i = 0; i < n; i++) deal(a[i]);
  int res = INF;
  for (int i = 1; i <= (int)2e5; i++)
    if (vis[i] == n) {
      res = min(res, cnt[i]);
    }
  printf("%d\n", res);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  solve();
  return 0;
}
