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