n, m, k = gets.chomp.split.map(&:to_i)
orange = []
n.times{orange << gets.to_i}
cost = [0]
for i in 0..(n-1)
    min = max = orange[i]
    s, min_cost = 1, cost[i] + k
    (i-1).downto(0){|j|
        s += 1
        break if s > m
        min = orange[j] if min > orange[j]
        max = orange[j] if max < orange[j]
        c = cost[j] + s * (max - min) + k
        min_cost = c if min_cost > c
    }
    cost[i+1] = min_cost
end
puts cost[n]
