#include <bits/stdc++.h>
using namespace std;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int a[100005];
int checked[1000005], n;
vector<int> ab[100005];
int get_cnt(int x) {
  int res = 0;
  int cur = x;
  vector<int> target;
  while (cur > 0) {
    target.push_back(cur & 1);
    cur /= 2;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    int ph = ab[i].size() - 1, pt = target.size() - 1;
    while (ph >= 0 && pt >= 0 && ab[i][ph] == target[pt]) {
      pt--;
      ph--;
    }
    cur = a[i];
    cur >>= (ph + 1);
    cnt += ph + 1;
    if (cur == x) {
      res += cnt;
      continue;
    }
    if (cur < x) {
      while (cur < x) {
        cur <<= 1;
        cnt++;
      }
    } else {
      while (cur > x) {
        cur >>= 1;
        cnt++;
      }
    }
    res += cnt;
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    int cur = a[i];
    while (cur > 0) {
      ab[i].push_back(cur & 1);
      cur /= 2;
    }
  }
  int prefix = 0;
  int ans = 100000000;
  for (int i = 0; i <= 17; i++) {
    bool ok = 1;
    if (ab[0].size() < i + 1) {
      ok = 0;
    } else {
      for (int j = 1; j < n; j++) {
        if (ab[j].size() < i + 1) {
          ok = 0;
          break;
        }
        if (ab[j][ab[j].size() - 1 - i] !=
            ab[j - 1][ab[j - 1].size() - 1 - i]) {
          ok = 0;
          break;
        }
      }
    }
    if (!ok) break;
    prefix <<= 1;
    prefix += ab[0][ab[0].size() - 1 - i];
  }
  for (int l = prefix; l <= 200000; l <<= 1) {
    ans = min(ans, get_cnt(l));
  }
  cout << ans;
  return 0;
}
