n, m, k = gets.split.map(&:to_i)
a = ['dummy'] + (1..n).map { gets.to_i }
t = [0]
(1..n).each do |i|
    min = Float::INFINITY
    max = -min
    opt = Float::INFINITY
    i.downto(1) do |j|
        break if i - j + 1 > m
        min = a[j] if a[j] < min
        max = a[j] if a[j] > max
        x = t[j-1] + k + (max - min) * (i - j + 1)
        opt = x if x < opt
    end
    t[i] = opt
end
p t[-1]
