#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

#ifdef _DEBUG
#define LOCAL
#endif

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 200 * 1000 + 41;
const ll INF = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL + 41;
const ll MAGIC = 31;

int n;
ll ans;
ll a[MAX];
ll deg[MAX];

ll suf[MAX];
ll pref[MAX];

bool cmp(pll a, pll b) {	
	ll x = a.first;
	ll y = b.first;
	ll mulx = max(0LL, min(a.second - b.second, MAGIC));
	ll muly = max(0LL, min(b.second - a.second, MAGIC));
	x *= (1LL << mulx);
	y *= (1LL << muly);
	return x < y;	
}

struct State {
	pll mini, maxi;
	ll q;
	State () {};
	State (pll mini, pll maxi, ll q) : mini(mini), maxi(maxi), q(q) {};	
};

ostream& operator<<(ostream& os, State &s) {
	cerr << endl;
	os << "{mini = " << s.mini << " maxi = " << s.maxi << " q = " << s.q << "}\n";
	return os;
};

void buildsuf() {
	vector<State> st;	
	ll cur = 0;
	fdi(n, 1) {
		State val = State(mp(a[i], deg[i]), mp(a[i], deg[i]), 1LL);		
		while (sz(st)) {
			State nxt = st.back();			
			if (!cmp(nxt.mini, val.maxi)) break;
			st.pop_back();
			while (cmp(nxt.mini, val.maxi)) {
				cur += nxt.q * 2;
				nxt.mini.second += 2;
				nxt.maxi.second += 2;
			}			
			val.q += nxt.q;
			val.maxi = nxt.maxi;
		}
		st.pb(val);
//		dbg(i);
//		dbg(st);		
		suf[i] = cur;
	}
	dbg1(suf, n);
}

void buildpref() {	
	vector<State> st;	
	ll cur = 0;
	fi(1, n) {
		State val = State(mp(a[i], deg[i] + 1), mp(a[i], deg[i] + 1), 1LL);		
		while (sz(st)) {
			State nxt = st.back();			
			if (!cmp(nxt.mini, val.maxi)) break;
			st.pop_back();
			while (cmp(nxt.mini, val.maxi)) {
				cur += nxt.q * 2;
				nxt.mini.second += 2;
				nxt.maxi.second += 2;
			}			
			val.q += nxt.q;
			val.maxi = nxt.maxi;
		}
		st.pb(val);
//		dbg(i);
//		dbg(st);		
		pref[i] = cur + i;
	}
	dbg1(pref, n);
}

void solve() {
	buildsuf();
	buildpref();
	ans = INF;
	fi(0, n) {
		ans = min(ans, pref[i] + suf[i + 1]);
	}	
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	
	scanf("%d", &n);
	fi(1, n) {
		scanf("%lld", &a[i]);
		while (a[i] % 2 == 0) {
			deg[i]++;
			a[i] /= 2;
		}
	}
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 18028