#include <bits/stdc++.h>
using namespace std;
int vis[100010], lev, r[100010], u[100010];
void go(int i, int k) {
  if (i > 100005 || vis[i] == lev) return;
  vis[i] = lev;
  r[i] += k;
  u[i]++;
  go(i * 2, k + 1);
  go(i / 2, k + 1);
}
int main() {
  int n;
  while (cin >> n) {
    vector<int> a(n);
    for (int i = 0; i < n; scanf("%d", &a[i++]))
      ;
    memset(vis, 0, sizeof vis);
    memset(r, 0, sizeof r);
    memset(u, 0, sizeof u);
    lev = 1;
    for (int i = 0; i < n; i++) go(a[i], 0), lev++;
    int res = 1e9;
    for (int i = 0; i < 100010; i++) {
      if (u[i] == n) res = min(res, r[i]);
    }
    cout << res << endl;
  }
  return 0;
}
