#include <bits/stdc++.h>
using namespace std;
int a, v[300005], c[300005];
map<int, pair<int, int> > mp;
void insertt(const int &cur, const int &cost, const int &i) {
  if (v[cur] != i) {
    mp[cur].second++;
    mp[cur].first += cost;
  } else if (c[cur] > cost) {
    mp[cur].first -= c[cur];
    mp[cur].first += cost;
    c[cur] = cost;
  }
  v[cur] = i;
}
void insertAll(int cur, int cost, int i) {
  while (cur <= 100000) {
    if (v[cur] != i)
      insertt(cur, cost, i);
    else
      break;
    cost++;
    cur *= 2;
  }
}
int main() {
  int n, cost = 0;
  scanf("%d", &n);
  int l = 1, g = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a);
    cost = 0;
    while (a >= 1) {
      insertAll(a, cost, i);
      cost++;
      a /= 2;
    }
  }
  int ans = 1234567890, cur;
  for (auto it : mp) {
    cur = it.second.second;
    if (n == cur) {
      ans = min(ans, it.second.first);
    }
  }
  cout << ans << endl;
}
