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]
(1...n).each do |i|
    while (a.size > 1 && (h[a[0]]-h[i])**2+dp[a[0]] > (h[a[1]]-h[i])**2+dp[a[1]])
        a.shift
    end
    dp[i] = (h[a[0]]-h[i])**2+c+dp[a[0]]
    while (a.size > 1 && !f(-2*h[a[-2]],h[a[-2]]**2+dp[a[-2]],-2*h[a[-1]],h[a[-1]]**2+dp[a[-1]],-2*h[i],h[i]**2+dp[i]))
        a.pop
    end
    a << i
end
puts dp[n-1]