Karaoke
It's karaoke night, and it's your turn to sing! One problem, you _might_ have overstated your vocal abilities. Luckily, you're a master of music theory, and might be able to save your voice.
The upcoming song has notes, with pitches
. You can choose not to sing at most
of these notes, without your friends noticing.
Your total "pitchiness" is equal to the difference of the pitches of consecutive notes you choose to sing.
For example, if you sing notes "1 4 5 2 3", your "pitchiness" is equal to:
What is the minimum pitchiness you are able to sing without your friends noticing?
Input
The first line consists of an integer
, the number of notes in the song.
The next line consists of an integer
, the maximum of notes in the song you are allowed to miss.
The last line contains notes
, representing the pitches of the notes in the song, in order.
Output
Output the minimum "pitchiness" of the song after removing at most notes.
Example
Input
5
2
10 0 9 0 8
Output
2
Remove the 2nd and 4th notes (both 0). The notes you do sing are "10 9 8", which has a pitchiness of .
Comments