#include <bits/stdc++.h>
using namespace std;
const int max_n = 100010;
int Count[max_n] = {0};
int Step[max_n] = {0};
int n, val, ans = INT_MAX;
int visit[max_n] = {0};
void bfs(int k) {
  queue<int> que;
  que.push(val);
  int dis = 1;
  Count[val]++;
  visit[val] = k;
  while (!que.empty()) {
    int S = que.size();
    while (S--) {
      int p = que.front();
      que.pop();
      if (p * 2 <= 1e5 && visit[p * 2] != k) {
        visit[p * 2] = k;
        Count[p * 2]++;
        Step[p * 2] += dis;
        que.push(p * 2);
      }
      if (p / 2 >= 1 && visit[p / 2] != k) {
        visit[p / 2] = k;
        Count[p / 2]++;
        Step[p / 2] += dis;
        que.push(p / 2);
      }
    }
    dis++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val);
    bfs(i);
  }
  for (int i = 1; i <= 1e5; i++) {
    if (Count[i] != n) continue;
    ans = min(ans, Step[i]);
  }
  printf("%d", ans);
  return 0;
}
