#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <limits>
#include <utility>
#include <iomanip>
#include <set>
#include <numeric>
#include <cassert>
#include <ctime>
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807LL
#define INF 2000000000
#define PI acos(-1.0)
#define EPS 1e-8
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))
#define bits(a) __builtin_popcount(a)
using namespace std;
int cnt[100005], vis[100005], steps[100005];
int main()
{
//ios_base::sync_with_stdio(0);
//freopen("lca.in", "r", stdin);
//freopen("lca.out", "w", stdout);
int n, res = INF, x, y;
scanf("%d", &n);
for(int i=1;i<=n;i++)
{
scanf("%d", &x);
queue<pair<int, int> > q;
q.push(mp(x, 0));
while(!q.empty())
{
x = q.front().f;
y = q.front().s;
q.pop();
if(x > 100003) continue;
if(vis[x] == i) continue;
vis[x] = i;
steps[x]+=y;
cnt[x]++;
q.push(mp(x * 2, y + 1));
q.push(mp(x / 2, y + 1));
}
}
for(int i=0;i<=100000;i++)
if(cnt[i] == n)
if(res > steps[i])
res = steps[i];
printf("%d", res);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxzc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxsaW1pdHM+CiNpbmNsdWRlIDx1dGlsaX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