#include <bits/stdc++.h>
using namespace std;
const int Max = 100005;
int cishu[Max];
int bushu[Max];
int main() {
  int n;
  int MM = 100000;
  while (cin >> n) {
    memset(cishu, 0, sizeof cishu);
    memset(bushu, 0, sizeof bushu);
    for (int i = 0; i < n; i++) {
      int num;
      cin >> num;
      int flag = 1;
      int bu = 0;
      while (num) {
        if (flag) {
          int tt = bu + 1;
          int num2 = num * 2;
          while (num2 <= MM) {
            cishu[num2]++;
            bushu[num2] += tt;
            num2 *= 2;
            tt++;
          }
          flag = 0;
        }
        cishu[num]++;
        bushu[num] += bu;
        bu++;
        if (num % 2 == 0)
          num /= 2;
        else {
          flag = 1;
          num /= 2;
        }
      }
    }
    int MI = 0x3f3f3f3f;
    for (int i = 1; i <= MM; i++) {
      if (cishu[i] == n) MI = min(MI, bushu[i]);
    }
    cout << MI << endl;
  }
  return 0;
}
