//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

// おためしLi Chao Tree
// 最小値習得

struct LiChaoTree {
    seg: Vec<(i64, i64)>,
    bit: usize,
    z: Vec<i64>,
}

const INF_LINE: (i64, i64) = (0, 2_000_000_000_000_000_001);

impl LiChaoTree {
    fn new(z: &Vec<i64>) -> Self {
        let mut z = z.clone();
        z.sort();
        z.dedup();
        let mut k = 0;
        while (1 << k) < z.len() {
            k += 1;
        }
        let p = *z.last().unwrap();
        while z.len() < (1 << k) {
            z.push(p);
        }
        LiChaoTree {
            seg: vec![INF_LINE; 2 << k],
            bit: k,
            z: z,
        }
    }
    //直線ax + b を追加
    fn update(&mut self, a: i64, b: i64) {
        let mut state = ((a, b), 1, 0, (1 << self.bit));
        loop {
            let ((a, b), k, l, r) = state;
            let (c, d) = self.seg[k];
            let fl = a * self.z[l] + b;
            let fr = a * self.z[r - 1] + b;
            let gl = c * self.z[l] + d;
            let gr = c * self.z[r - 1] + d;
            if fl >= gl && fr >= gr {
                break;
            }
            if fl <= gl && fr <= gr {
                self.seg[k] = (a, b);
                break;
            }
            let m = (l + r) / 2;
            let fm = a * self.z[m] + b;
            let gm = c * self.z[m] + d;
            state = if fr >= gr && fm >= gm {
                ((a, b), 2 * k, l, m)
            } else if fr >= gr {
                self.seg[k] = (a, b);
                ((c, d), 2 * k + 1, m, r)
            } else if fm >= gm {
                ((a, b), 2 * k + 1, m, r)
            } else {
                self.seg[k] = (a, b);
                ((c, d), 2 * k, l, m)
            };
        }
    }
    fn find(&self, x: i64) -> i64 {
        let k = self.z.binary_search(&x).unwrap();
        let mut y = k + (1 << self.bit);
        let mut res = std::i64::MAX;
        while y >= 1 {
            let (a, b) = self.seg[y];
            res = std::cmp::min(res, a * x + b);
            y >>= 1;
        }
        res
    }
}

fn run() {
    input! {
        n: usize,
        c: i64,
        h: [i64; n],
    }
    let mut cht = LiChaoTree::new(&h);
    cht.update(-2 * h[0], h[0] * h[0]);
    let mut dp = vec![0; n];
    for i in 1..n {
        dp[i] = c + h[i] * h[i] + cht.find(h[i]);
        cht.update(-2 * h[i], dp[i] + h[i] * h[i]);
    }
    println!("{}", dp[n - 1]);
}

fn main() {
    run();
}


Measured memory_bytes: 21880