#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int n;
  cin >> n;
  const int N = 1e5 + 5;
  vector<int> cnt(N, 0), val(N, 0);
  for (int i = 0; i < n; ++i) {
    int x, cur = 1;
    cin >> x;
    int tp = 2 * x;
    while (tp < N) {
      cnt[tp]++;
      val[tp] += cur;
      cur++;
      tp *= 2;
    }
    cur = 0;
    while (x) {
      cnt[x]++;
      val[x] += cur;
      if (x & 1) {
        int tmp = x - 1, ctmp = cur + 2;
        while (tmp && tmp < N) {
          cnt[tmp]++;
          val[tmp] += ctmp;
          tmp *= 2;
          ctmp += 1;
        }
      }
      x /= 2;
      cur++;
    }
  }
  int ans = INT_MAX;
  for (int i = 1; i < N; ++i)
    if (cnt[i] == n) ans = min(ans, val[i]);
  cout << ans << '\n';
}
