#include <bits/stdc++.h>
using namespace std;
const int INF = -1u >> 2;
const int maxn = 1e5 + 1;
int input[maxn], cnt[maxn], total[maxn], N, M;
bool visit[maxn];
struct node {
  int x, s;
  node(int x = 0, int s = 0) : x(x), s(s) {}
} Q[maxn];
int front, rear, now;
void BFS(int t) {
  memset(visit, 0, sizeof visit);
  visit[t] = true;
  ++total[t];
  for (Q[0] = node(t), front = 0, rear = 1; front != rear; ++front) {
    for (int i = 0; i < 2; ++i) {
      if (i)
        now = Q[front].x >> 1;
      else
        now = Q[front].x << 1;
      if (now < 0 || now > M || visit[now]) continue;
      visit[now] = true;
      ++total[now];
      Q[rear++] = node(now, Q[front].s + 1);
    }
  }
  for (int i = 0; i < rear; ++i) cnt[Q[i].x] += Q[i].s;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> input[i], M = max(M, input[i]);
  for (int i = 0; i < N; ++i) BFS(input[i]);
  int Ans = INF;
  for (int i = 0; i <= M; ++i)
    if (total[i] == N) Ans = min(Ans, cnt[i]);
  cout << Ans << endl;
  return 0;
}
