#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int to_array(int *s, int a) {
  int len = log2(a + 0.5) + 1;
  memset(s, 0, sizeof(33 * 4));
  int t = len;
  while (a > 0) {
    s[--t] = (a & 1);
    a >>= 1;
  }
  return len;
}
int to(int a, int b) {
  int sa[33], sb[33];
  int la = to_array(sa, a);
  int lb = to_array(sb, b);
  int i, t;
  for (i = 0; i < la && i < lb; i++) {
    if (sa[i] != sb[i]) {
      break;
    }
  }
  t = i;
  for (; i < lb; i++) {
    if (sb[i] == 1) {
      return INF;
    }
  }
  return la - t + lb - t;
}
const int N = 100009;
int s[N][33], a[N], n;
int solve(int k) {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += to(a[i], k);
  }
  return ans;
}
int main() {
  int minl = INF;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    minl = min(minl, to_array(s[i], a[i]));
  }
  int t, k = 0;
  for (t = 0; t < minl; t++) {
    bool dift = false;
    for (int i = 1; i < n; i++) {
      if (s[i][t] != s[0][t]) {
        dift = true;
        break;
      }
    }
    if (dift) {
      break;
    }
    k = ((k << 1) | s[0][t]);
  }
  int ans = solve(k);
  for (; t < 30; t++) {
    k <<= 1;
    ans = min(ans, solve(k));
  }
  printf("%d\n", ans);
  return 0;
}
