use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let a = i.read_vec::<usize>(n);

    writeln!(o, "{}", solve(a)).unwrap();
}
fn counts(a: &[usize]) -> Vec<usize> {
    let mut ss = vec![[None; 16]; a.len()];
    let mut rs = Vec::with_capacity(a.len() + 1);
    let mut cs = Vec::with_capacity(a.len());

    rs.push(0);
    rs.push(0);

    let mut ds = Vec::with_capacity(a.len() - 1);

    for i in 1..a.len() {
        let mut d = 0isize;
        let mut a0 = a[i - 1];
        let mut a1 = a[i];
        while a0 < a1 {
            a0 *= 4;
            d += 1;
        }
        while a0 >= a1 * 4 {
            a1 *= 4;
            d -= 1;
        }
        ds.push(d);

        cs.clear();
        let mut c = 0;
        let mut j = i;
        while j > 0 {
            let mut c_ext = 0;
            if c >= 16 {
                c_ext = c - 16 + 1;
                c -= c_ext;
            }

            if let Some(c_j) = ss[j][c] {
                c = c_j + c_ext * (j + 1);
                break;
            }
            cs.push((c, c_ext));
            c = max(c as isize + ds[j - 1], 0) as usize;
            j -= 1;
        }
        while let Some((c_j, c_j_ext)) = cs.pop() {
            j += 1;
            ss[j][c_j] = Some(c + c_j);
            c += c_j + c_j_ext * (j + 1);
        }
        rs.push(c);
    }
    rs
}
fn solve(mut a: Vec<usize>) -> usize {
    let cs0 = counts(&a);
    a.reverse();
    let cs1 = counts(&a);

    (0..a.len())
        .map(|x| cs0[x] * 2 + x + cs1[a.len() - x] * 2)
        .min()
        .unwrap()
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 66808