#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100000 + 7;
const double eps = 1e-7;
const long long mod = 19650827;
const int INF = 0x3f3f3f3f;
int n;
int a[MAXN];
int sum = INF;
int num[300005];
int check(int from, int to) {
  if (to > from) {
    int k = 0;
    while (from) {
      if (from == to) return k;
      if (to % from == 0 && (num[to / from])) {
        return k + num[to / from];
      }
      from /= 2;
      k++;
    }
    return -1;
  } else if (to == from)
    return 0;
  else {
    int k = 0;
    while (from) {
      if (from >= to && from % to == 0 && (num[from / to])) {
        return k + num[from / to];
      }
      if (from < to && to % from == 0 && num[to / from]) {
        return k + num[to / from];
      }
      if (to == from) return k;
      from /= 2;
      k++;
    }
    return -1;
  }
}
void judge(int x) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int p = check(a[i], x);
    if (p == -1) return;
    ans += p;
  }
  sum = min(sum, ans);
}
int check1(int from, int to) {
  int t = from;
  int ans = 0;
  while (!num[t] && t != 1) {
    t /= 2;
    ans++;
  }
  ans += abs(num[t] - num[to]);
  return ans;
}
void judge1(int x) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (num[a[i]]) {
      ans += abs(num[x] - num[a[i]]);
    } else {
      ans += check1(a[i], x);
    }
  }
  sum = min(ans, sum);
}
int main(int argc, char const *argv[]) {
  int k = 1;
  int t = 0;
  while (k < 300005) {
    num[k] = t++;
    k *= 2;
  }
  scanf("%d", &n);
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
  }
  int p = mx;
  while (mx) {
    judge(mx);
    judge(mx * 2);
    mx /= 2;
  }
  int f = 1;
  while (f <= p) {
    judge1(f);
    f *= 2;
  }
  printf("%d\n", sum);
  return 0;
}
