#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
int vis[100005];
void run() {
  int n = in();
  vector<pair<int, int> > ac(100005, make_pair(0, 0));
  int ans = 2000000000;
  for (int i = (1); i < (n + 1); i++) {
    int x = in();
    queue<pair<int, int> > q;
    q.push(make_pair(x, 0));
    while (!q.empty()) {
      pair<int, int> cur = q.front();
      q.pop();
      if (cur.first >= 100005) continue;
      if (vis[cur.first] == i) continue;
      vis[cur.first] = i;
      ac[cur.first].first++;
      ac[cur.first].second += cur.second;
      if (ac[cur.first].first == n) {
        ans = min(ans, ac[cur.first].second);
      }
      q.push(make_pair(cur.first >> 1, cur.second + 1));
      q.push(make_pair(cur.first << 1, cur.second + 1));
    }
  }
  printf("%d\n", ans);
}
int main() {
  run();
  return 0;
}
