#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int dist[100005], DIST[100005], cnt[100005], vis[100005], maxi;
void BFS(int num, int turn) {
  queue<int> Q;
  Q.push(num);
  dist[num] = 0;
  vis[num] = turn;
  int cur, temp;
  while (!Q.empty()) {
    cur = Q.front();
    Q.pop();
    DIST[cur] += dist[cur];
    cnt[cur]++;
    temp = cur * 2;
    if (temp <= maxi && vis[temp] != turn) {
      vis[temp] = turn;
      dist[temp] = dist[cur] + 1;
      Q.push(temp);
    }
    temp = cur / 2;
    if (vis[temp] != turn) {
      vis[temp] = turn;
      dist[temp] = dist[cur] + 1;
      Q.push(temp);
    }
  }
}
int main() {
  int n;
  maxi = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    maxi = max(maxi, arr[i]);
  }
  memset(vis, -1, sizeof vis);
  for (int i = 0; i < n; i++) {
    BFS(arr[i], i);
  }
  int res = 1 << 30;
  for (int i = 1; i <= 100000; i++) {
    if (cnt[i] != n) continue;
    res = min(res, DIST[i]);
  }
  printf("%d\n", res);
}
