#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = 1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 1e5 + 5;
vector<int> P[100001];
bool chk[100001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    queue<int> Q, C;
    vector<int> w;
    Q.push(a);
    C.push(0);
    w.push_back(a);
    P[a].push_back(0);
    chk[a] = true;
    while (!Q.empty()) {
      int f = Q.front();
      Q.pop();
      int c = C.front();
      C.pop();
      if (f * 2 <= 100000 && !chk[f * 2]) {
        chk[f * 2] = true;
        w.push_back(f * 2);
        Q.push(f * 2);
        P[f * 2].push_back(c + 1);
        C.push(c + 1);
      }
      if (f / 2 >= 1 && !chk[f / 2]) {
        chk[f / 2] = true;
        w.push_back(f / 2);
        Q.push(f / 2);
        P[f / 2].push_back(c + 1);
        C.push(c + 1);
      }
    }
    for (int j = 0; j < w.size(); j++) {
      chk[w[j]] = false;
    }
    chk[a] = false;
  }
  int ans = INT_MAX;
  for (int i = 1; i <= 100000; i++) {
    if (P[i].size() == n) {
      int x = 0;
      for (int j = 0; j < P[i].size(); j++) {
        x += P[i][j];
      }
      ans = ans < x ? ans : x;
    }
  }
  printf("%d\n", ans);
}
