A gas station too far

There is just one road connecting the n+1n+1 cities c0,,cnc_0, \dots, c_n consecutively. You want to go from c0c_0 to cnc_n stopping at most ss times to fill the tank of the car. There are gas stations at the cities, but none on the roads. The length of each road is 0,,n1\ell_0, \dots, \ell_{n-1}. Which is the minimum range for your car? Suppose that you start with a full tank.

Input

Input consists of several cases. Every case begins with nn and ss, which are followed by nn natural numbers 0,,n1\ell_0, \dots, \ell_{n-1}. Suppose 1n1051 \le n \le 10^5, 0sn10 \le s \le n - 1, and 1i1041 \le \ell_i \le 10^4.

Output

For every case, print the minimum range for a car to reach cnc_n starting from c0c_0 stopping at most ss times to fill the tank.

Hint

Consider a decisional version of this problem.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T10:18:51.759Z

© Jutge.org, 2006–2026.
https://jutge.org