Super platforms
In many classic 2D games, you might encounter a scenario where a hero jumps across platforms (or islands) suspended in the air. The goal is to move from one side of the screen to the other. When the hero jumps from one platform to the next, he expends energy equal to |y2–y1|, where y2 and y1 are the heights of the respective platforms. Additionally, the hero has a special move that allows him to skip a platform, costing 3·|y2–y1| energy units. The number of times this special move can be used is limited, ranging from kmin to kmax times (inclusive). Naturally, the hero should aim to minimize energy expenditure.
Given the heights of all platforms from left to right and the constraints on the number of special moves, can you determine the minimum energy required for the hero to travel from the first platform to the last?
Input
The first line contains the number of platforms n (1 ≤ n ≤ 10000).
The second line lists n natural numbers, each not exceeding 30000, representing the heights of the platforms.
The third line provides two non-negative integers kmin and kmax (0 ≤ kmin ≤ kmax ≤ (n–1)/2).
Output
Output a single number — the minimum energy the hero must spend to traverse the platforms (assuming no cheat codes are used).
Explanation of Examples
It's optimal to jump without using the special move (using it 0 times).
The hero must use the special move exactly once, with no alternative but to jump directly from the first platform to the last.
It's beneficial to use one special move to leap from the first platform to the last.
There are effectively no special moves available (amount=0), so the hero must jump sequentially through each platform.