Many frogs are eager to cross a river. The river is units wide, but each frog can jump a maximum distance of units, where l < w. Luckily, there are stones scattered across the river that can assist them in reaching the other side.
These stones are positioned at integer distances from the starting bank. At a distance from the starting bank, there are a_i stones available. Each stone can support only one frog before it sinks. Determine the maximum number of frogs that can successfully cross the river using these stones.
The first line contains two integers and (1 \leq l < w \leq 10^5) – representing the width of the river and the maximum distance a frog can jump.
The second line provides w-1 integers a_1, a_2, \ldots, a_{w-1} (0 \leq a_i \leq 10^4) – indicating the number of stones available at each respective distance.
Print a single integer – the maximum number of frogs that can reach the opposite bank.
Example 1
Example 2