def calc_cost(i,j,c)
    return (i-j)**2+c
end

def f(a1,b1,a2,b2,a3,b3)
    return (b3-b2)*(a2-a1) >= (b2-b1)*(a3-a2)
end

n,c = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
dp = Array.new(n,0)
a = [0]
for i in 1..n-1
    while a.size > 1 && calc_cost(h[i],h[a[0]],dp[a[0]]) > calc_cost(h[i],h[a[1]],dp[a[1]])
        a.shift
    end
    dp[i] = calc_cost(h[i],h[a[0]],dp[a[0]])+c
    while a.size > 1 && f(-2*h[a[-2]],dp[a[-2]]+h[a[-2]]**2,-2*h[a[-1]],dp[a[-1]]+h[a[-1]]**2,-2*h[i],dp[i]+h[i]**2)
        a.pop
    end
    a.push(i)
end
p dp[-1]