#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int cnt[N], steps[N], vis[N];
void solve() {
  int n, res = INT_MAX, x, y;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> x;
    queue<pair<int, int>> q;
    q.push({x, 0});
    while (!q.empty()) {
      x = q.front().first;
      y = q.front().second;
      q.pop();
      if (x > N) continue;
      if (vis[x] == i) continue;
      vis[x] = i;
      steps[x] += y;
      cnt[x]++;
      q.push({2 * x, y + 1});
      q.push({x / 2, y + 1});
    }
  }
  for (int i = 0; i < N; i++) {
    if (cnt[i] == n) {
      if (res > steps[i]) res = steps[i];
    }
  }
  cout << res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cerr.tie(0);
  ;
  int t = 1;
  while (t--) solve();
}
