Question
Fair Load Cap

You are given n positive workloads in a fixed order and m workers.

Split the array into exactly m non-empty contiguous groups. A worker receives one group, and that worker's load is the sum of its group.

Minimize the maximum load assigned to any worker.

Input

The first line contains KaTeX can only parse string typed expression and KaTeX can only parse string typed expression.
The second line contains KaTeX can only parse string typed expression positive integers.

Output

Print the minimum possible value of the maximum group sum.

Example
Input:
5 2

7 2 5 10 8
Output:
18
Explanation:
Split as [7, 2, 5] and [10, 8]. The maximum load is 18, and no split can make it smaller.

Online