#include <bits/stdc++.h>
using namespace std;
int n;
int a[200000];
char stra[200000][20];
int lena[200000];
char tmp[20];
int t;
int commonlen;
int ansa;
int dista;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    memset(tmp, 0, sizeof(tmp));
    t = a[i];
    int j = 0;
    for (;; j++) {
      if (t == 0) {
        break;
      }
      tmp[j] = t & 1;
      t >>= 1;
    }
    tmp[j] = -1;
    for (int k = 0; k < j; k++) {
      stra[i][k] = tmp[j - 1 - k];
    }
    stra[i][j] = -1;
    lena[i] = j;
  }
  commonlen = lena[0];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < commonlen; j++) {
      if (stra[0][j] != stra[i][j]) {
        commonlen = j;
        break;
      }
    }
  }
  int sumlen = 0;
  int maxlen = 0;
  for (int i = 0; i < n; i++) {
    for (int j = commonlen; j < lena[i]; j++) {
      if (stra[i][j] == 1) {
        stra[i][j] = -1;
        ansa += lena[i] - j;
        lena[i] = j;
        break;
      }
    }
    sumlen += lena[i];
    maxlen = max(maxlen, lena[i]);
  }
  int suma = 1 << 30;
  int tmpsuma = 0;
  for (int j = 0; j <= maxlen; j++) {
    tmpsuma = 0;
    for (int i = 0; i < n; i++) {
      tmpsuma += abs(lena[i] - j);
    }
    suma = min(suma, tmpsuma);
  }
  cout << suma + ansa << endl;
  return 0;
}
