#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  int mx = *max_element(a.begin(), a.end());
  vector<int> vis(mx + 1, -1), cnt(mx + 1), dis(mx + 1, 0);
  for (int i = 0; i < n; i++) {
    int s = a[i];
    queue<pair<int, int>> q;
    q.emplace(s, 0);
    while (!q.empty()) {
      int x, d;
      tie(x, d) = q.front();
      q.pop();
      if (x > mx or vis[x] == i) continue;
      cnt[x]++;
      vis[x] = i;
      dis[x] += d;
      q.emplace(x * 2, d + 1);
      q.emplace(x / 2, d + 1);
    }
  }
  int res = 2e9;
  for (int s = 0; s <= mx; s++) {
    if (cnt[s] == n and res > dis[s]) res = dis[s];
  }
  cout << res << '\n';
}
