#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, a[maxn];
vector<string> v;
string read() {
  int x;
  scanf("%d", &x);
  string ret;
  while (x) {
    char ch = '0' + (x & 1);
    ret = ch + ret;
    x >>= 1;
  }
  return ret;
}
int jud(int pos) {
  for (int i = 1; i < n; i++)
    if (v[i][pos] != v[0][pos]) return 0;
  return 1;
}
int main() {
  while (~scanf("%d", &n)) {
    v.clear();
    int len = -1;
    for (int i = 0; i < n; i++) {
      v.push_back(read());
      if (len == -1 || len > v[i].size()) len = v[i].size();
    }
    int pre = 0;
    for (int i = 0; i < len && jud(i); i++) pre++;
    for (int i = 0; i < n; i++) {
      a[i] = -1;
      for (int j = pre; j < v[i].size(); j++)
        if (v[i][j] == '1') {
          a[i] = j + 1;
          break;
        }
    }
    int ans = -1;
    for (int i = pre; i < 30; i++) {
      int tmp = 0;
      for (int j = 0; j < n; j++) {
        int val = 0;
        if (a[j] == -1 || a[j] > i)
          val += abs(i - (int)v[j].size());
        else {
          val += (int)v[j].size() - a[j] + 1;
          val += abs(i - (a[j] - 1));
        }
        tmp += val;
      }
      if (ans == -1 || ans > tmp) ans = tmp;
    }
    printf("%d\n", ans);
  }
  return 0;
}
