#include <bits/stdc++.h>
using namespace std;
int A[(int)1e5 + 5];
int dep;
int Map[(int)1e5 + 5], go[(int)1e5 + 5], cnt[(int)1e5 + 5];
void BT(int x, int k) {
  if (x > (int)1e5 || !x || go[x] == dep) return;
  go[x] = dep;
  cnt[x]++;
  Map[x] += k;
  BT(x * 2, k + 1);
  BT(x / 2, k + 1);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  dep = 1;
  int res = (int)1e9;
  for (int i = 0; i < n; i++) BT(A[i], 0), dep++;
  for (int i = 0; i < 100001; i++) {
    if (cnt[i] == n) res = min(res, Map[i]);
  }
  cout << res << endl;
}
