#include <bits/stdc++.h>
using namespace std;
int n, a[100010], ans, vis[100010], step[100010];
struct Node {
  int x;
  int step;
};
void cpp(int x, int s) {
  vis[x]++;
  step[x] += s;
  int way = 0, xx = x, xxx;
  while (2 * xx < 100010) {
    xx *= 2;
    way++;
    step[xx] += way;
    vis[xx]++;
  }
  way = 0;
  xx = x;
  while (xx / 2 > 0) {
    if (xx == 1) break;
    if (xx % 2 == 1) {
      xxx = xx / 2;
      int wayy = way + 1;
      while (xxx * 2 < 100010) {
        wayy++;
        xxx *= 2;
        vis[xxx]++;
        step[xxx] += wayy;
      }
    }
    xx /= 2;
    way++;
    vis[xx]++;
    step[xx] += way;
  }
}
int main() {
  int MIN;
  while (~scanf("%d", &n)) {
    MIN = 99999999;
    memset(vis, 0, sizeof(vis));
    memset(step, 0, sizeof(step));
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      cpp(a[i], 0);
    }
    for (int i = 0; i < 100010; i++) {
      if (vis[i] == n) {
        if (step[i] < MIN) {
          MIN = step[i];
        }
      }
    }
    printf("%d\n", MIN);
  }
}
