#include <bits/stdc++.h>
using namespace std;
int a[200008], sign[200008];
int b[200008];
int main() {
  int n;
  scanf("%d", &n);
  int t;
  memset(a, 0, sizeof(a));
  memset(sign, 0, sizeof(sign));
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    int k = t;
    int time = 0;
    b[i] = t;
    while (k) {
      a[k] += time;
      sign[k]++;
      if (k & 1 && k > 1) {
        int kk = k / 2 * 2, tim = time + 2;
        while (kk < 200008) {
          a[kk] += tim;
          sign[kk]++;
          kk <<= 1;
          tim++;
        }
      }
      k >>= 1;
      time++;
    }
    k = t, time = 0;
    while (k < 200008) {
      a[k] += time;
      sign[k]++;
      k <<= 1;
      time++;
    }
    sign[t]--;
  }
  int res = 0x3f3f3f3f;
  for (int i = 1; i < 200008; i++) {
    if (sign[i] == n) {
      res = min(res, a[i]);
    }
  }
  printf("%d\n", res);
}
