#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = (int)1e9;
long long INFF = 8000000000000000000LL;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
long long inp[100006], cnt[100006], dist[100006], vis[100006];
queue<pair<int, int> > Q;
int main() {
  int n, temp;
  pair<int, int> p;
  scanf("%d", &n);
  for (int(i) = (1); (i) < (n + 1); (++i)) {
    scanf("%d", &temp);
    Q.push(make_pair(temp, 0));
    while (!Q.empty()) {
      p = Q.front();
      Q.pop();
      if (p.first > 100005 || !(p.first)) continue;
      if (vis[p.first] == i) continue;
      vis[p.first] = i;
      cnt[p.first]++;
      dist[p.first] += p.second;
      Q.push(make_pair(2 * p.first, p.second + 1));
      Q.push(make_pair(p.first / 2, p.second + 1));
    }
  }
  long long ret = 1e18;
  for (int(i) = (1); (i) < (1e5 + 5); (++i)) {
    if (cnt[i] != n) continue;
    ret = min(ret, dist[i]);
  }
  cout << ret << endl;
  return 0;
}
