#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const int maxn = 100005;
int d[maxn];
int f[maxn];
void possibleMasks(int a, int j) {
  int x = 0;
  while (a) {
    int b = a, y = 0;
    while (b < maxn) {
      if (f[b] == j - 1) {
        d[b] += x + y;
        f[b] = j;
      }
      b <<= 1;
      ++y;
    }
    while (a & 1 == 0) {
      a >>= 1;
      ++x;
    }
    a >>= 1;
    ++x;
  }
  d[0] += x;
}
int main() {
  int n, a;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a);
    possibleMasks(a, i);
  }
  int m = inf;
  for (int i = 0; i < maxn; ++i)
    if (f[i] == n) m = min(m, d[i]);
  printf("%d", m);
}
