#include <bits/stdc++.h>
using namespace std;
int n;
int cnt[100005], step_table[100005], visit[100005];
int ans, tmp, max_num;
typedef struct {
  int num, step;
} node;
int main(void) {
  while (1 == scanf("%d", &n)) {
    memset(step_table, 0, sizeof(step_table));
    memset(cnt, 0, sizeof(cnt));
    memset(visit, -1, sizeof(visit));
    max_num = -1;
    for (int i = 0; i < n; i++) {
      scanf("%d", &tmp);
      max_num = max(max_num, tmp);
      node A;
      A.num = tmp;
      A.step = 0;
      queue<node> q;
      q.push(A);
      while (!q.empty()) {
        node cur = q.front();
        q.pop();
        if (cur.num > 100000 || cur.num < 1) continue;
        if (visit[cur.num] == i) continue;
        visit[cur.num] = i;
        step_table[cur.num] += cur.step;
        cnt[cur.num]++;
        node newA = cur, newB = cur;
        newA.num >>= 1;
        newA.step += 1;
        q.push(newA);
        newB.num <<= 1;
        newB.step += 1;
        q.push(newB);
      }
    }
    ans = 1e9;
    for (int i = max_num; i > 0; i--) {
      if (cnt[i] == n) {
        ans = min(ans, step_table[i]);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
