#include <bits/stdc++.h>
using namespace std;
long long int b[200000 + 10], c[200000 + 10],
    vis[200000 + 10] = {0}, val[200000 + 10] = {0};
int main() {
  long long int i, n;
  cin >> n;
  long long int maxx = -1;
  for (i = 1; i <= n; i++) {
    cin >> c[i];
    b[i] = c[i];
    maxx = max(maxx, c[i]);
  }
  maxx = maxx;
  for (i = 1; i <= n; i++) {
    long long int ans = 0;
    while (b[i] >= 1) {
      vis[b[i]]++;
      val[b[i]] += ans;
      ans++;
      if (b[i] % 2 != 0 && b[i] != 1) {
        vis[(b[i] / 2) * 2]++;
        val[(b[i] / 2) * 2] += ans + 1;
        long long int k = (b[i] / 2) * 4;
        long long int z = ans + 2;
        while (k <= maxx) {
          vis[k]++;
          val[k] += z;
          z++;
          k = k * 2;
        }
      }
      b[i] = b[i] / 2;
    }
  }
  for (i = 1; i <= n; i++) {
    long long int ans = 1;
    c[i] = c[i] * 2;
    while (c[i] <= maxx) {
      vis[c[i]]++;
      val[c[i]] += ans;
      ans++;
      c[i] = c[i] * 2;
    }
  }
  long long int MIN = INT_MAX;
  for (i = 1; i <= maxx; i++) {
    if (MIN > val[i] && vis[i] >= n) MIN = val[i];
  }
  cout << MIN << endl;
  return 0;
}
