#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int N = 200000;
int n;
int m;
int was[N + 1];
int d[N + 1];
int q[N + 1];
int res[N + 1];
int cnt[N + 1];
int ct;
int go(int x) {
  ct++;
  int l = 0, r = 1;
  q[0] = x;
  was[x] = ct;
  d[x] = 0;
  while (l < r) {
    int x = q[l++];
    res[x] += d[x];
    cnt[x]++;
    if (x / 2 >= 1 && was[x / 2] != ct) {
      was[x / 2] = ct;
      d[x / 2] = d[x] + 1;
      q[r++] = x / 2;
    }
    if (x * 2 <= N && was[x * 2] != ct) {
      was[x * 2] = ct;
      d[x * 2] = d[x] + 1;
      q[r++] = x * 2;
    }
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    go(x);
  }
  int ans = 1e9;
  for (int i = 1; i <= N; i++)
    if (cnt[i] == n) ans = min(ans, res[i]);
  printf("%d\n", ans);
  return 0;
}
