#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
int n, a[MAXN], vis[MAXN], cnt[MAXN];
int main() {
  while (~scanf("%d", &n)) {
    memset(vis, 0, sizeof(vis));
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
      int step = 0, temp = a[i];
      while (temp < MAXN) {
        vis[temp]++;
        cnt[temp] += step;
        temp <<= 1;
        step++;
      }
      step = 0;
      while (a[i] > 1) {
        if (a[i] & 1) {
          int temp = a[i] >> 1;
          int p = step + 2;
          temp <<= 1;
          while (temp < MAXN) {
            vis[temp]++;
            cnt[temp] += p;
            temp <<= 1;
            p++;
          }
        }
        a[i] >>= 1;
        vis[a[i]]++;
        step++;
        cnt[a[i]] += step;
      }
    }
    int ans = 0x3f3f3f3f;
    for (int i = 0; i <= 1e5; i++) {
      if (vis[i] == n) {
        ans = min(ans, cnt[i]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
