output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: /*input
  8
  657312726 129662684 181537270 324043958 468214806 916875077 825989291 319670097
  */
  
  #include <algorithm>
  #include <iostream>
  #include <string.h>
  #include <stdlib.h>
  #include <iomanip>
  #include <utility>
  #include <vector>
  #include <queue>
  #include <stack>
  #include <map>
  #include <set>
  #include <math.h>
  
  using namespace std;
  
  #define pb                push_back
  #define pp                pop_back
  #define pf                pop_front
  #define nl                cout << "\n"
  #define MIN(con)          (*min_element(ALL(con))) 
  #define MAX(con)          (*max_element(ALL(con)))
  #define ALL(cont)         (cont).begin(),(cont).end()
  #define NX(cont)          next_permutation(ALL(cont))
  #define PX(cont)          prev_permutation(ALL(cont))
  #define prec(n)           cout << fixed << setprecision(n)
  #define PI                3.14159265358979323846264338327951
  #define FH(it,c)          for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)
  #define ff                first
  #define ss                second
  #define all(c)            c.begin(),c.end()
  #define fill(a,v)         memset(a,v,sizeof a)
  #define rep(i,a,b)        for(ll i=a;i<b;i++)
  #define rrep(i,a,b)       for(ll i=a;i>=b;i--)
  #define srep(i,s)         for(ll i=0;s[i]!='\0';i++)
  #define nn                cout<<"\n"
  #define sp                cout<<" "
  #define mod               1000000007    //9
  #define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)
  
  using ll = long long;
  typedef vector<ll> vll;
  typedef vector<char> vc;
  typedef vector<string> vst;
  typedef pair<ll,ll> pll;
  typedef pair<char,ll> pcl;
  typedef pair<string,ll> psl;
  typedef set<ll> sll;
  typedef set<char> sc;
  typedef set<string> sst;
  typedef map<char,ll> mcl;
  typedef map<ll,ll> mll;
  typedef map<string,ll> msl;
  
  using ld = long double;
   
  template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
  template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
  template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
  template < typename T > inline void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int
  
  inline ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
  inline ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
  inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }
  
  inline ll powr(ll a, ll b){
      ll x = 1LL;
      while(b) {
          if(b & 1) x = mul(x, a);
          a = mul(a, a);
          b >>= 1;
      }
      return x;
  }
  
  inline ll inv(ll a) { return powr(a, mod - 2);}
  
  const int inv2 = (mod + 1) >> 1;
  const ll INF =  999999999999999999;
  const int inf = 999999999;
  
  bool check(ll n)
  {
      if(n == 1) return 0;
      if(n == 2 or n == 3) return 1;
      if(n % 2 == 0 or n % 3 == 0) return 0;
  
      for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
      return 1;
  }
  
  
  /*********************************************START**************************************************************/
  
  int main()
  {
      ifalse;
      int n;
      cin >> n;
      vector < ll > a(n);	
      rep(i,0, n) {
      	cin >> a[i];
      }
      if(n == 1) {
      	return cout << "0", nl, 0;
      } 
  
      ll cnt = 0;
      if(a[0] > a[1]) {
      	cnt ++;
      	a[0] *= -2;
      }
      for(int i = 2; i < n; i ++) {
      	if(a[i - 1] > a[i]) {
      		if((a[i - 1]  * (-2LL)) >= a[i - 2]) {
      			a[i - 1] *= -2LL;
      			cnt ++;
      		}
      		while(a[i - 1] > a[i]) {
      			a[i] *= 4LL;
      			cnt += 2;
      			if(a[i] < 0) {
      				cout << "-1";
      				return 0;
      			}
      		}
      	}
      }
      cout << cnt, nl;
      return 0;
  }
problem_description: Statement
  
  There are N positive integers A_1, A_2, ..., A_N. Takahashi can perform the
  following operation on these integers any number of times:
  
    * Choose 1 \leq i \leq N and multiply the value of A_i by -2.
  
  Notice that he multiplies it by **minus** two.
  
  He would like to make A_1 \leq A_2 \leq ... \leq A_N holds. Find the minimum
  number of operations required. If it is impossible, print `-1`.
samples: [{"input": "4\n    3 1 4 1", "output": "3\n    \n\nOne possible solution is:\n\n  * Choose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now 3, 1, 4, -2.\n  * Choose i=1 and multiply the value of A_1 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, -2.\n  * Choose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, 4.\n\n* * *"}, {"input": "5\n    1 2 3 4 5", "output": "0\n    \n\nA_1 \\leq A_2 \\leq ... \\leq A_N holds before any operation is performed.\n\n* * *"}, {"input": "8\n    657312726 129662684 181537270 324043958 468214806 916875077 825989291 319670097", "output": "7"}]