Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/qidiruv-kitoblarni-taqsimlash

Allocating books

Medium 1000 ms 128 MB 60%
Share

$n$ books stand in a row on a shelf, the $i$-th book has $a_{i}$ pages. The books must be divided among $k$ students: each student gets at least one book, the books of one student stand next to each other on the shelf, and every book goes to exactly one student. The number of pages of the student who gets the most pages must be as small as possible. Find this number.

Book columns on the shelf split into consecutive parts, the largest part sum highlighted

Input

The first line contains two positive integers: $n$ and $k$. The second line contains $n$ positive integers $a_{i}$ separated by spaces.

Output

One integer — the smallest possible number of pages of the student who gets the most pages.

Note

$1 \le k \le n \le 10^{5}$
$1 \le a_{i} \le 10^{4}$

Examples

Input #1
5 2
10 20 30 40 50
Output #1
90
Input #2
4 4
7 2 9 4
Output #2
9

Sign in to submit a solution

Signing up is free and takes a minute.