mod lichao {
    use std;
    type T = i64;
    const INF: T = std::i64::MAX;
    fn get_mid(l: T, r: T) -> T {
        (l + r) / 2
    }
    #[derive(Clone, Copy)]
    pub struct Line(T, T);
    impl Line {
        fn eval(&self, x: T) -> T {
            self.0 * x + self.1
        }
    }
    type Link = Option<Box<Node>>;
    struct Node {
        line: Line,
        left: Link,
        right: Link,
    }
    impl Node {
        fn find(node: &Link, left: T, right: T, x: T) -> T {
            let mut node = node;
            let mut ans = INF;
            let mut l = left;
            let mut r = right;
            while let Some(t) = node.as_ref() {
                let val = t.line.eval(x);
                if val < ans {
                    ans = val;
                }
                let m = get_mid(l, r);
                node = if x < m {
                    r = m;
                    &t.left
                } else {
                    l = m;
                    &t.right
                };
            }
            ans
        }
        fn insert(node: &mut Link, l: T, r: T, mut line: Line) {
            if node.is_none() {
                *node = Some(Box::new(Node {
                    line: line,
                    left: None,
                    right: None,
                }));
                return;
            }
            let node = node.as_mut().unwrap();
            if node.line.eval(l) > line.eval(l) {
                std::mem::swap(&mut node.line, &mut line);
            }
            let m = get_mid(l, r);
            if node.line.eval(r) < line.eval(r) {
                return;
            } else if node.line.eval(m) < line.eval(m) {
                Node::insert(&mut node.right, m, r, line);
            } else {
                std::mem::swap(&mut node.line, &mut line);
                Node::insert(&mut node.left, l, m, line);
            }
        }
    }
    pub struct LiChaoTree {
        root: Link,
        left: T,
        right: T,
    }
    impl LiChaoTree {
        pub fn new(left: T, right: T) -> Self {
            LiChaoTree {
                root: None,
                left: left,
                right: right,
            }
        }
        pub fn insert(&mut self, a: T, b: T) {
            Node::insert(&mut self.root, self.left, self.right, Line(a, b));
        }
        pub fn find(&self, x: T) -> T {
            assert!(self.left <= x && x < self.right);
            Node::find(&self.root, self.left, self.right, x)
        }
    }
}

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let c: i64 = it.next().unwrap().parse().unwrap();
    let h: Vec<i64> = it.map(|s| s.parse().unwrap()).collect();
    let mut cht = lichao::LiChaoTree::new(1, 1_000_000 + 1);
    cht.insert(-2 * h[0], c + h[0] * h[0]);
    for &h in h[1..(n - 1)].iter() {
        let v = cht.find(h) + h * h;
        cht.insert(-2 * h, v + c + h * h);
    }
    let ans = cht.find(h[n - 1]) + h[n - 1] * h[n - 1];
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 14584