#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int nmax = 101234;
int n, a[nmax], flg[nmax], cnt[nmax], res;
queue<pair<int, int> > q2;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int flg2, tmp, tmp2, i = 0; i < n; ++i) {
    tmp = a[i];
    tmp2 = 0;
    flg2 = 1;
    while (tmp) {
      if (flg2 == 1) q2.push({tmp, tmp2});
      if (tmp % 2 != 0)
        flg2 = 1;
      else
        flg2 = 0;
      ++flg[tmp];
      cnt[tmp] += tmp2++;
      tmp /= 2;
    }
    while (!q2.empty()) {
      tmp = q2.front().first * 2;
      tmp2 = q2.front().second;
      q2.pop();
      while (tmp < 100012) {
        ++flg[tmp];
        cnt[tmp] += ++tmp2;
        tmp *= 2;
      }
    }
  }
  res = INT_MAX;
  for (int i = 1; i < 100012; ++i)
    if (flg[i] == n && res > cnt[i]) res = cnt[i];
  printf("%d", res);
  return 0;
}
