#include <bits/stdc++.h>
using namespace std;
int cnt[100005], steps[100005], x, y, i, res = 2e9, vis[100005], n;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    queue<pair<int, int> > q;
    q.push(make_pair(x, 0));
    while (q.size()) {
      x = q.front().first;
      y = q.front().second;
      q.pop();
      if (x > 1e5 + 1) continue;
      if (vis[x] == i) continue;
      cnt[x]++;
      steps[x] += y;
      vis[x] = i;
      q.push(make_pair(x * 2, y + 1));
      q.push(make_pair(x / 2, y + 1));
    }
  }
  for (i = 0; i <= 1e5; i++)
    if (cnt[i] == n) res = min(res, steps[i]);
  printf("%d", res);
}
