#include <bits/stdc++.h>
int scan() {
  int noRead = 0;
  char p = getchar();
  for (; p < 33;) {
    p = getchar();
  }
  while (p > 32) {
    noRead = (noRead << 3) + (noRead << 1) + (p - '0');
    p = getchar();
  }
  return noRead;
}
using namespace std;
int a[100010], ans[100010];
int nreach[100010];
int main(void) {
  int n;
  cin >> n;
  memset(nreach, 0, sizeof(nreach));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int moves = 0;
  for (int i = 0; i < n; ++i) {
    int elem = a[i];
    while (elem) {
      nreach[elem]++;
      if (elem > 1) moves++;
      elem /= 2;
    }
  }
  ans[0] = 0;
  ans[1] = moves;
  int output = moves;
  for (int i = 2; i <= 100010; ++i) {
    if ((i % 2) && nreach[i] < n) {
      ans[i] = 100000001;
      continue;
    }
    ans[i] = ans[i / 2] + n - nreach[i] - nreach[i];
    output = min(ans[i], output);
  }
  cout << output;
  return 0;
}
