#include <bits/stdc++.h>
using namespace std;
string s[100010];
int a[100010];
int calLcp(string s1, string s2) {
  int res = 0;
  for (int i = 0; i < (int)s1.size() && i < (int)s2.size(); i++) {
    if (s1[i] == s2[i]) {
      res++;
    } else {
      return res;
    }
  }
  return res;
}
string lcp(string *s, int n) {
  int len = s[0].size();
  for (int i = 1; i < n; i++) {
    len = min(len, calLcp(s[i - 1], s[i]));
  }
  return s[0].substr(0, len);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s[i] = "";
    int x = a[i];
    while (x) {
      s[i] += '0' + (x & 1);
      x >>= 1;
    }
    reverse(s[i].begin(), s[i].end());
  }
  string res = lcp(s, n);
  int len = res.size(), ans = -1;
  for (int zeros = 0; zeros <= 30; zeros++) {
    int tmpRes = 0;
    for (int i = 0; i < n; i++) {
      int pos = -1;
      for (int j = len; j < (int)s[i].size(); j++) {
        if (s[i][j] == '1') {
          pos = j;
          break;
        }
      }
      if (pos == -1) {
        tmpRes += abs(len + zeros - (int)s[i].size());
      } else {
        tmpRes += (int)s[i].size() - pos;
        tmpRes += abs(len + zeros - pos);
      }
    }
    if (zeros == 0 || ans > tmpRes) {
      ans = tmpRes;
    }
  }
  printf("%d\n", ans);
  return 0;
}
