#include <bits/stdc++.h>
using namespace std;
int n;
map<int, pair<int, long long int> > a;
int used[100001];
void rec(int x, int y, int z) {
  if (x > 100003 || used[x] == z || x == 0) {
    return;
  } else {
    a[x].first++;
    a[x].second += y;
    used[x] = z;
    rec(x * 2, y + 1, z);
    rec(x / 2, y + 1, z);
  }
}
int main() {
  int x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    rec(x, 0, i);
  }
  int ans = 2000000000;
  for (int i = 1; i <= 100003; i++) {
    if (a[i].first == n) {
      if (ans > a[i].second) ans = a[i].second;
    }
  }
  printf("%d", ans);
}
