#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> v;
vector<long long> m;
vector<long long> used;
vector<long long> cnt;
vector<long long> val;
inline void fill(long long p) {
  queue<pair<long long, long long>> q;
  q.push({v[p], 1});
  while (!q.empty()) {
    auto x = q.front();
    q.pop();
    used[x.first] = p + 1;
    m[x.first] = x.second;
    cnt[x.first]++;
    val[x.first] += x.second - 1;
    if (used[x.first / 2] != p + 1) {
      q.push({x.first / 2, x.second + 1});
    }
    if (x.first * 2 <= 1e5 && used[x.first * 2] != p + 1) {
      q.push({x.first * 2, x.second + 1});
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  v.resize(n);
  m.resize(1e5 + 1);
  val.resize(1e5 + 1);
  cnt.resize(1e5 + 1);
  used.resize(1e5 + 1);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) fill(i);
  long long anw = 1e9;
  for (int i = 0; i <= 1e5; i++)
    if (cnt[i] == n) anw = min(anw, val[i]);
  cout << anw << endl;
}
