#Q182. 「一本通 5.5 练习 1」烽火传递

「一本通 5.5 练习 1」烽火传递

Description

Original source: NOIP 2010 Senior Division Preliminary Round · Problem Completion

Beacon towers are crucial military defense installations, typically built along major transportation routes or strategic locations. In case of military activity, smoke signals are used during the day and fire signals at night to relay information.

Between two cities, there are nn beacon towers, each with a certain cost to send a signal. To ensure accurate transmission of intelligence, at least one out of every consecutive mm beacon towers must send a signal. Given nn, mm, and the cost of each beacon tower, compute the minimum total cost required to accurately transmit information between the two cities.

Input Format

The first line contains nn and mm, representing the number of beacon towers nn and the consecutive tower count mm.

The second line contains nn integers, each denoting the cost aia_i of the corresponding beacon tower.

Output Format

Output a single integer, the minimum cost.

Sample 1

Send signals from the 2nd and 5th beacon towers.

5 3
1 2 5 6 2

4

Data Range and Hint

For all data, 1n,m2×1051\le n,m\le 2\times 10^5, and 1ai10001\le a_i\le 1000.