#include <bits/stdc++.h>
using namespace std;
vector<int> movesReqdArr;
vector<int> canReachCountArr;
vector<int> vis;
void solve(int x, int MX, int k) {
  queue<pair<int, int> > q;
  canReachCountArr[x]++;
  vis[x] = k;
  q.push(make_pair(x, 0));
  while (!q.empty()) {
    pair<int, int> elem = q.front();
    int a = elem.first, movesReqdToA = elem.second;
    q.pop();
    int b = a >> 1, c = a << 1;
    if (b > 0 && vis[b] != k) {
      int movesReqdToB = movesReqdToA + 1;
      q.push(make_pair(b, movesReqdToB));
      canReachCountArr[b]++;
      vis[b] = k;
      movesReqdArr[b] += movesReqdToB;
    }
    if (c <= MX && vis[c] != k) {
      int movesReqdToC = movesReqdToA + 1;
      q.push(make_pair(c, movesReqdToC));
      canReachCountArr[c]++;
      vis[c] = k;
      movesReqdArr[c] += movesReqdToC;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, j;
  int n;
  cin >> n;
  ;
  int MX = 0;
  vector<int> arr(n);
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    MX = max(MX, arr[i]);
  }
  movesReqdArr = vector<int>(MX + 1, 0);
  canReachCountArr = vector<int>(MX + 1, 0);
  vis = vector<int>(MX + 1, -1);
  for (i = 0; i < n; i++) solve(arr[i], MX, i);
  int ans = INT_MAX;
  for (i = 0; i < MX + 1; i++) {
    if (canReachCountArr[i] != n) continue;
    ans = min(ans, movesReqdArr[i]);
  }
  cout << ans << '\n';
}
