#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const int MAXN = 5 + 100000;
int tc[MAXN], idx;
vector<ii> used[MAXN];
vector<int> us2;
void add(int num, int st) {
  int& minst = tc[num];
  if (minst == -1) {
    minst = st;
    us2.push_back(num);
  }
  minst = min(minst, st);
}
void forw(int x, int d) {
  while (x < MAXN) {
    add(x, d);
    x *= 2;
    ++d;
  }
}
void process(int x) {
  int d = 0;
  while (x >= 1) {
    forw(x, d);
    add(x, d);
    ++d;
    x /= 2;
  }
  for (const int& p : us2) {
    used[idx].emplace_back(p, tc[p]);
    tc[p] = -1;
  }
  us2.clear();
}
ii all[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  memset(tc, -1, sizeof tc);
  int n;
  cin >> n;
  for (; idx < n; ++idx) {
    int x;
    cin >> x;
    process(x);
  }
  for (int i = (int)1; i < (int)MAXN; ++i) {
    all[i] = {0, 0};
  }
  int ans = numeric_limits<int>::max();
  for (int i = (int)0; i < (int)n; ++i) {
    const auto& mi = used[i];
    for (const auto& p : mi) {
      all[p.first].second += p.second;
      if (++all[p.first].first == n) {
        ans = min(ans, all[p.first].second);
      }
    }
  }
  assert(ans != numeric_limits<int>::max());
  cout << ans << '\n';
  return 0;
}
