#include <bits/stdc++.h>
using namespace std;
const int oo = 10000000;
int f(int a, int k) {
  int aa = a;
  int u = 0;
  while (a > k) {
    a /= 2;
    u++;
  }
  if (a == k) return u;
  while (k > a) {
    a *= 2;
    u++;
  }
  if (a == k) return u;
  return 1 + f(aa / 2, k);
}
int b[100005];
set<int> s;
set<int>::iterator it;
int main() {
  int n, i, a, minn = oo, su, k, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    s.insert(a);
    b[i] = a;
  }
  while (s.size() != 1) {
    it = s.end();
    it--;
    su = (*it) / 2;
    s.erase(it);
    s.insert(su);
  }
  k = *s.begin();
  int pq = 18;
  if (k != 1) pq = log(200000.0) / log(1.0 * k);
  for (j = 0; j <= pq; j++) {
    su = 0;
    for (i = 0; i < n; i++) su += f(b[i], k);
    if (su < minn) minn = su;
    k *= 2;
  }
  cout << minn << endl;
  return 0;
}
