#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, M = 1e6 + 5;
long long n, m, a[N], cnt[N], sz[N], son[N][2], dep[N], root, res, ans;
void dfs(long long x, long long fa) {
  sz[x] = cnt[x], dep[x] = dep[fa] + 1;
  for (long long i = 0; i < 2; i++) {
    long long y = son[x][i];
    if (y) dfs(y, x), sz[x] += sz[y];
  }
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld", &a[i]), m = max(m, a[i]), cnt[a[i]]++;
  for (long long i = 1; i <= m; i++) {
    if (i * 2 <= m) son[i][0] = i * 2;
    if (i * 2 + 1 <= m) son[i][1] = i * 2 + 1;
  }
  dfs(1, 0);
  for (long long i = m; i >= 1; i--)
    if (sz[i] == n) {
      root = i;
      break;
    }
  for (long long i = 1; i <= n; i++) res += dep[a[i]] - dep[root];
  ans = res;
  for (long long i = root; i <= m; i *= 2)
    res -= sz[i * 2], res += n - sz[i * 2], ans = min(ans, res);
  printf("%lld\n", ans);
  return 0;
}
