// Try KEYENCE Programming Contest 2019
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
	macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let d = get!();
    let mut xs = vec![];
    for _ in 0..n {
    	let x = get!();
        xs.push(x);
    }
    let mut ans = 0_i64;
    let mut flag = vec![false; n];
    
    let mut p = (0,1);
    let mut c = std::i64::MAX;
    for i in 0..n {
    	for j in i+1..n {
        	let t = (i-j).abs() as i64
            	* d + xs[i] + xs[j];
			if t < c {
            	c = t;
                p = (i, j);
            }
        }
    }
    flag[p.0] = true;
    flag[p.1] = true;
    let mut ans = c;
    let mut p = (0,1);
    let mut c = std::i64::MAX;
    for i in 0..n {
    	if !flag[i] { continue; }
    	for j in i+1..n {
        	if flag[j] { continue; }
        	let t = (i-j).abs() as i64
            	* d + xs[i] + xs[j];
			if t < c {
            	c = t;
                p = (i, j);
            }
        }
    }
    flag[p.0] = true;
    flag[p.1] = true;
    ans += c;
    println!("{}, ans);
    
    
}