#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double eps = 1e-6;
int n, a[N], d[N], cnt[N], vis[N];
void dfs(int u, int dep, int id) {
  if (u > N || !u) return;
  if (vis[u] == id) return;
  vis[u] = id;
  cnt[u]++;
  d[u] += dep;
  dfs(u >> 1, dep + 1, id);
  dfs(u << 1, dep + 1, id);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), dfs(a[i], 0, i);
  int best = INF;
  for (int i = 1; i < N; i++)
    if (cnt[i] == n) best = min(best, d[i]);
  cout << best << endl;
  return 0;
}
