#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9 + 7;
const int N = (int)1e5 + 10;
int cnt[N];
int vis[N];
int dis[N];
int vs = 1;
void bfs(int u) {
  queue<pair<int, int> > q;
  q.push({u, 0});
  while ((int)((q).size()) > 0) {
    pair<int, int> p = q.front();
    q.pop();
    if (p.first >= N || p.first <= 0 || vis[p.first] == vs) continue;
    vis[p.first] = vs;
    dis[p.first] += p.second;
    cnt[p.first]++;
    q.push({p.first * 2, p.second + 1});
    q.push({p.first / 2, p.second + 1});
  }
  ++vs;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    bfs(x);
  }
  int ans = oo;
  for (int i = 1; i <= N; ++i)
    if (cnt[i] == n) ans = min(ans, dis[i]);
  printf("%d", ans);
  return 0;
}
