#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
int state[100001];
int foi[100001];
int s[100001];
int MAX = 100001;
void gera(int v, int op, int col) {
  int cont = v;
  int x = cont;
  while (cont > 0) {
    int aux = op;
    x = cont;
    while (x < MAX) {
      if (s[x] == col) break;
      s[x] = col;
      state[x] += aux;
      foi[x]++;
      x = 2 * x;
      aux++;
    }
    cont = cont / 2;
    op++;
  }
  state[0] += op;
  foi[0]++;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(n);
  memset(s, 0, sizeof(s));
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  int col = 0;
  for (int i = 0; i < n; i++) gera(v[i], 0, ++col);
  int resp = INF;
  for (int i = 0; i < 100001; i++)
    if (foi[i] == n) resp = min(resp, state[i]);
  printf("%d\n", resp);
  return 0;
}
