#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5;
vector<pair<long long, long long> > op(N + 1, {0, 0});
vector<long long> visited(N + 1, 0);
void bfs(long long s, long long it) {
  queue<pair<long long, long long> > q;
  q.push({s, 0});
  while (!q.empty()) {
    long long x = q.front().first;
    long long dist = q.front().second;
    q.pop();
    if (visited[x] == it) continue;
    visited[x] = it;
    op[x] = {op[x].first + 1, op[x].second + dist};
    if ((x << 1) <= N) {
      q.push({(x << 1), dist + 1});
    }
    if (x) {
      q.push({x >> 1, dist + 1});
    }
  }
}
int32_t main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long &x : a) cin >> x;
  long long k = 1;
  for (auto x : a) {
    bfs(x, k++);
  }
  long long minm = LLONG_MAX;
  for (long long i = 0; i <= N; ++i) {
    if (op[i].first == n) {
      minm = min(minm, op[i].second);
    }
  }
  cout << minm;
}
