#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, c: i64,
        h: [i64;n]
    }

    let mut dp = vec![0i64;n];
    dp[0] = 0;
    let mut cht = ConvexHullTrick::new(|l,r| l >= r);
    for i in 1..n {
        cht.add((-2*h[i-1], dp[i-1] + h[i-1] * h[i-1]));
        dp[i] = cht.cget(h[i]) + h[i] * h[i] + c;
    }
    println!("{}", dp[n-1]);
}

#[allow(dead_code)]
type Line = (i64, i64);
#[allow(dead_code)]
struct ConvexHullTrick {
    lines: std::collections::VecDeque<Line>,
    comp: Box<Fn(i64, i64) -> bool>,
}
#[allow(dead_code)]
impl ConvexHullTrick {
    #[doc = " min query: comp = |l,r| l >= r"]
    fn new<B>(comp: B) -> ConvexHullTrick
    where
        B: Fn(i64, i64) -> bool + 'static,
    {
        ConvexHullTrick {
            lines: std::collections::VecDeque::new(),
            comp: Box::new(comp),
        }
    }
    #[doc = " check l2 is redundant"]
    fn check(mut l1: Line, l2: Line, mut l3: Line) -> bool {
        if l1 < l3 {
            std::mem::swap(&mut l1, &mut l3);
        }
        (l3.1 - l2.1) * (l2.0 - l1.0) >= (l2.1 - l1.1) * (l3.0 - l2.0)
    }
    #[doc = " add y=ax+b, a1>=a2>=a3>=..."]
    fn add(&mut self, line: Line) {
        while self.lines.len() >= 2
            && Self::check(
                self.lines[self.lines.len() - 2],
                self.lines[self.lines.len() - 1],
                line,
            )
        {
            self.lines.pop_back();
        }
        self.lines.push_back(line);
    }
    fn f(&self, i: usize, x: i64) -> i64 {
        self.lines[i].0 * x + self.lines[i].1
    }
    #[doc = " return min value at x"]
    fn get(&self, x: i64) -> i64 {
        let mut ng = -1i64;
        let mut ok = self.lines.len() as i64 - 1;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            if (self.comp)(self.f(mid as usize, x), self.f(mid as usize + 1, x)) {
                ng = mid;
            } else {
                ok = mid;
            }
        }
        self.f(ok as usize, x)
    }
    #[doc = " return min value at x, x1 <= x2 <= x3 <= ..."]
    fn cget(&mut self, x: i64) -> i64 {
        fn y(l: Line, x: i64) -> i64 {
            l.0 * x + l.1
        }
        while self.lines.len() >= 2 && (self.comp)(y(self.lines[0], x), y(self.lines[1], x)) {
            self.lines.pop_front();
        }
        y(self.lines[0], x)
    }
}

Measured memory_bytes: 13428