#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double eps = 1e-8;
const int nm = 100005;
int n, m, k, t;
int res;
int sl[nm], to[nm];
void goup(int v, int gt) {
  int j = gt;
  while (v < 100004) {
    sl[v]++;
    to[v] += j++;
    v <<= 1;
  }
}
void doit(int v) {
  int x = v, j = 0;
  goup(x << 1, 1);
  while (x) {
    if (x & 1 && x != 1) goup(x - 1, j + 2);
    sl[x]++;
    to[x] += j;
    j++;
    x >>= 1;
  }
}
int main() {
  int i, j, x, y, z, u, v, w;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    doit(x);
  }
  res = MOD;
  for (i = 1; i <= 100002; i++)
    if (sl[i] == n && to[i] < res) {
      res = to[i];
    }
  cout << res;
  return 0;
}
