#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t A[200000];
int64_t countr[200010];
int64_t countl[200010];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> A[i];
	}


	{
		std::map<int32_t, std::pair<int64_t, int64_t>> chain;//s, *4^s
		auto count_size = [&](auto iter) {
			auto next = std::next(iter);
			if (next != chain.end()) {
				return (next->first - iter->first);
			}
			else {
				return (N - iter->first);
			}
		};
		chain[N - 1] = { 0, 0 };
		countr[N - 1] = countr[N] = 0;
		for (int i = N - 2; i >= 0; i--)
		{
			countr[i] = countr[i + 1];
			if (A[i] > A[i + 1]) {
				int64_t add = 0;
				for (int64_t c = A[i + 1]; A[i] > c; c *= 4) {
					add += 2;
				}

				auto iter = chain.begin();
				//iter->second.first += add;
				iter->second.second += add;
				countr[i] += add * count_size(iter);
				{
					bool reach_end = true;
					auto next = std::next(iter);
					while (next != chain.end())
					{
						int a = 0;
						for (int64_t c = A[next->first - 1]; A[next->first] >= c; c *= 4) {
							a += 2;
						}
						if (a <= (iter->second.second - 0)) {
							auto tmp = *next;
							add = ((iter->second.second - 0) - a + 2);
							iter->second.second = next->second.second + add;
							countr[i] += add * count_size(next);
							next = chain.erase(next);
						}
						else {
							reach_end = false;
							break;
						}
					}

					auto bch = *chain.begin();
					chain.erase(chain.begin());
					chain[i] = bch.second;
				}
			}
			else {
				chain[i] = { 0,0 };
			}
		}
	}

	{
		std::map<int32_t, std::pair<int64_t, int64_t>> chain;//s, *4^s
		auto count_size = [&](auto iter) {
			auto next = std::next(iter);
			if (next != chain.rend()) {
				return -(next->first - iter->first);
			}
			else {
				return (1 + iter->first);
			}
		};
		chain[0] = { 0,0 };
		countl[1] = countl[0] = 0;
		for (int i = 1; i < N; ++i)
		{
			countl[i] = countl[i - 1];
			if (A[i] > A[i - 1]) {
				int64_t add = 0;
				for (int64_t c = A[i - 1]; A[i] > c; c *= 4) {
					add += 2;
				}

				auto iter = chain.rbegin();
				iter->second.second += add;
				countl[i] += add * count_size(iter);
				{
					bool reach_end = true;
					auto next = std::next(iter);
					while (next != chain.rend())
					{
						int64_t a = 0;
						for (int64_t c = A[next->first + 1]; A[next->first] >= c; c *= 4) {
							a += 2;
						}
						if (a <= (iter->second.second - 0)) {
							auto tmp = *next;
							add = ((iter->second.second - 0) - a + 2);
							iter->second.second = next->second.second + add;
							countl[i] += add * count_size(next);
							chain.erase(--(next.base()));
						}
						else {
							reach_end = false;
							break;
						}
					}
					if (reach_end) {
					}

					auto bch = *--chain.end();
					chain.erase(--chain.end());
					chain[i] = bch.second;
				}
			}
			else {
				chain[i] = { 0,0 };
			}
		}
	}


	int64_t min = countr[0];
	for (int64_t i = 1; i <= N; i++)
	{
		min = std::min(min, countl[i - 1] + countr[i] + i);
	}
	out << min << endl;

	return 0;
}
#endif


Measured memory_bytes: 17408