#include <bits/stdc++.h>
using namespace std;
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
int A[100008];
int B[100008];
int main() {
  int n = getnum();
  for (int y = 1; y <= n; y++) {
    int x = getnum();
    for (int j = 0; x > 0;) {
      int r = x * 2;
      for (int i = j + 1; r <= 100000; i++, r *= 2) A[r] += i, B[r]++;
      while (x % 2 == 0) {
        B[x]++;
        A[x] += j;
        j++;
        x /= 2;
      }
      B[x]++;
      A[x] += j;
      x /= 2;
      j++;
    }
  }
  int mn = INT_MAX;
  for (int i = 1; i <= 100000; i++)
    if (B[i] == n) mn = min(mn, A[i]);
  cout << mn;
}
