#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 3e5 + 10;
const int mod = 1e9 + 7;
int dp[MAXN];
int visit[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  memset(dp, 0, sizeof(dp));
  memset(visit, 0, sizeof(visit));
  for (int i = 1; i <= n; ++i) {
    int a;
    scanf("%d", &a);
    int x = a;
    int cnt = 0;
    while (x <= 1e5) {
      visit[x]++;
      dp[x] += cnt;
      cnt++;
      x <<= 1;
    }
    cnt = 0;
    while (a) {
      if (a & 1 && a != 1) {
        x = a - 1;
        int cntx = cnt + 2;
        while (x <= 1e5) {
          visit[x]++;
          dp[x] += cntx;
          cntx++;
          x <<= 1;
        }
      }
      a >>= 1;
      cnt++;
      visit[a]++;
      dp[a] += cnt;
    }
  }
  int ans = INF;
  for (int i = 1; i <= 1e5; ++i) {
    if (visit[i] == n) ans = min(ans, dp[i]);
  }
  printf("%d\n", ans);
  return 0;
}
