#include <bits/stdc++.h>
using namespace std;
int const maxn = 200005;
int cnt[maxn];
int cur_len[maxn];
int ans[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int const inf = 1000000000;
  for (int i = 0; i < maxn; ++i) cur_len[i] = inf;
  int n = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    cin >> cur;
    cur_len[cur] = 0;
    for (int tmp = cur, l = 0; tmp > 0; tmp /= 2, ++l) {
      for (int j = tmp, l2 = l; j < maxn; j *= 2, ++l2)
        if (cur_len[j] > l2) cur_len[j] = l2;
    }
    for (int tmp = cur; tmp > 0; tmp /= 2) {
      for (int j = tmp; j < maxn; j *= 2) {
        if (cur_len[j] < inf) {
          ++cnt[j];
          ans[j] += cur_len[j];
          cur_len[j] = inf;
        }
      }
    }
  }
  int ret = ans[1];
  for (int i = 2; i < maxn; ++i)
    if (cnt[i] == n && ans[i] < ret) ret = ans[i];
  cout << ret << endl;
}
