#include <bits/stdc++.h>
using namespace std;
const int OO = (int)1e9 + 7;
const int MAX = (int)1e5 + 5;
const int mod = (int)1e9 + 9;
int n, x[MAX], tg;
int calc(int a) {
  int cnt = 0;
  if (a == tg) return 0;
  while (a) {
    int cur = a, cc = cnt;
    while (cur <= tg) {
      if (cur == tg) return cnt;
      cur <<= 1;
      cnt++;
    }
    cnt = cc;
    a >>= 1;
    cnt++;
  }
  return -1;
}
int f(int i) {
  if (i == n) return 0;
  int steps = calc(x[i]);
  if (steps == -1) return OO;
  return f(i + 1) + steps;
}
int main(void) {
  while (cin >> n) {
    int res = OO, mx = -1;
    for (int i = 0; i < n; i++) {
      scanf("%d", &x[i]);
      mx = max(mx, x[i]);
    }
    int cur = mx;
    while (cur) {
      int up = cur;
      while (up <= mx) {
        tg = up;
        res = min(res, f(0));
        up <<= 1;
      }
      cur >>= 1;
    }
    cout << res << "\n";
  }
  return 0;
}
