#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int c[100005];
int main() {
  int n, ans = 1e9, x, y, temp;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &temp);
    queue<pair<int, int> > q;
    q.push(make_pair(temp, 0));
    while (!q.empty()) {
      x = q.front().first;
      y = q.front().second;
      q.pop();
      if (x >= 100001) continue;
      if (b[x] == i) continue;
      b[x] = i;
      c[x] += y;
      a[x]++;
      q.push(make_pair(x * 2, y + 1));
      q.push(make_pair(x / 2, y + 1));
    }
  }
  for (int i = 0; i <= 100000; ++i) {
    if (a[i] == n) {
      if (ans > c[i]) ans = c[i];
    }
  }
  printf("%d", ans);
}
