#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  scanf("%d", &n);
  int a[n];
  int maximum = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    if (a[i] > maximum) maximum = a[i];
  }
  int mark[100006] = {0};
  int moves[100006] = {0};
  for (int i = 0; i < n; i++) {
    int curElem = a[i];
    int bigcounter = 0;
    while (curElem >= 1) {
      int temp = curElem;
      int counter = 0;
      while (temp <= maximum) {
        mark[temp]++;
        moves[temp] += (bigcounter + counter);
        temp = temp * 2;
        counter++;
      }
      while (curElem % 2 == 0) {
        curElem = curElem / 2;
        mark[curElem]++;
        bigcounter++;
        moves[curElem] += bigcounter;
      }
      curElem = curElem / 2;
      bigcounter++;
    }
  }
  int answer = 1000000006;
  for (int i = 1; i <= maximum; i++) {
    if (mark[i] >= n && moves[i] < answer) answer = moves[i];
  }
  printf("%d\n", answer);
  return 0;
}
