#include <bits/stdc++.h>
using namespace std;
bool myFunc(pair<int, int> p1, pair<int, int> p2) {
  return (p1.first < p2.first) ||
         (p1.first == p2.first && p1.second < p2.second);
}
int main() {
  int n;
  cin >> n;
  int* arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int* count = new int[100001];
  int* ways = new int[100001];
  for (int i = 0; i < 100001; i++) {
    count[i] = 0;
    ways[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    int volume = arr[i];
    int way_count = 0;
    vector<pair<int, int> > vect;
    bool goSearch = true;
    while (volume >= 1) {
      int curr_volume = volume;
      int curr_count = way_count;
      vect.push_back(make_pair(curr_volume, curr_count));
      curr_count++;
      curr_volume *= 2;
      if (goSearch) {
        while (curr_volume <= 100000) {
          vect.push_back(make_pair(curr_volume, curr_count));
          curr_count++;
          curr_volume *= 2;
        }
      }
      if (volume % 2 == 0) {
        goSearch = false;
      } else {
        goSearch = true;
      }
      volume /= 2;
      way_count++;
    }
    sort(vect.begin(), vect.end(), myFunc);
    int curr_volume = vect[0].first;
    ways[curr_volume] += vect[0].second;
    count[curr_volume]++;
    for (unsigned int i = 1; i < vect.size(); i++) {
      if (curr_volume == vect[i].first) {
        continue;
      }
      curr_volume = vect[i].first;
      ways[curr_volume] += vect[i].second;
      count[curr_volume]++;
    }
  }
  int min = 10000000;
  for (int i = 0; i < 100001; i++) {
    if (count[i] == n && min > ways[i]) {
      min = ways[i];
    }
  }
  cout << min << endl;
  return 0;
}
