#include <bits/stdc++.h>
using namespace std;
map<int, int> mps;
vector<int> v;
bool visited[100005];
vector<vector<int> > vv;
void getup(int x, long long stps) {
  if (x > v[v.size() - 1]) return;
  if (x < 1) return;
  if (visited[x]) return;
  vv[x].push_back(stps);
  visited[x] = true;
  mps[x]++;
  getup(x * 2, stps + 1);
  getup(x / 2, stps + 1);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 100005; i++) {
    vector<int> temp;
    vv.push_back(temp);
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    int x = v[i];
    memset(visited, false, sizeof(visited));
    getup(x, 0);
  }
  long long anss = INT_MAX;
  int chr = 0;
  for (map<int, int>::iterator it = mps.begin(); it != mps.end(); ++it) {
    if (it->second == n) {
      int x = it->first;
      long long ans = 0;
      for (int i = 0; i < vv[x].size(); i++) {
        ans += vv[x][i];
      }
      if (ans < anss) chr = x;
      anss = min(ans, anss);
    }
  }
  cout << anss << endl;
}
