#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 200010;
int c1[maxn];
int c2[maxn];
int a[maxn];
int mx;
void up(int x, int sum) {
  while (x <= mx) {
    c1[x]++;
    c2[x] += sum;
    ++sum;
    x <<= 1;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (1), _end = (n); i <= _end; ++i) {
    scanf("%d", &a[i]);
    mx = max(a[i], mx);
  }
  mx <<= 1;
  for (int i = (1), _end = (n); i <= _end; ++i) {
    int x = a[i];
    int sum = 0;
    while (x >= 1) {
      if ((x & 1) && x > 1) {
        up(x ^ 1, sum + 2);
      }
      c1[x]++;
      c2[x] += sum;
      ++sum;
      x >>= 1;
    }
    up(a[i] << 1, 1);
  }
  int ans = 1e9;
  for (int i = (1), _end = (mx); i <= _end; ++i) {
    if (c1[i] == n) {
      ans = min(ans, c2[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
