#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int amax = *max_element(a.begin(), a.end());
  vector<int> vis(amax + 1, -1);
  vector<int> cnt(amax + 1, 0);
  vector<int> step(amax + 1, 0);
  for (int i = 0; i < n; ++i) {
    queue<pair<int, int>> q;
    q.push(make_pair(a[i], 0));
    while (!q.empty()) {
      int x = q.front().first;
      int y = q.front().second;
      q.pop();
      vis[x] = i;
      cnt[x]++;
      step[x] += y;
      if (x * 2 <= amax && vis[x * 2] != i) q.push(make_pair(x * 2, y + 1));
      if (x / 2 > 0 && vis[x / 2] != i) q.push(make_pair(x / 2, y + 1));
    }
  }
  int res = 1e9;
  for (int x = 1; x <= amax; ++x) {
    if (cnt[x] != n) continue;
    res = min(res, step[x]);
  }
  cout << res << "\n";
  return 0;
}
