[ABC319D] 最小换行窗宽 (Minimum Width)
Problem Statement
Takahashi is displaying a sentence with words in a window. All words have the same height, and the width of the -th word is .
The words are displayed in the window separated by a space of width . More precisely, when the sentence is displayed in a window of width , the following conditions are satisfied.
-
The sentence is divided into several lines.
-
The first word is displayed at the beginning of the top line.
-
The -th word is displayed either with a gap of after the -th word, or at the beginning of the line below the line containing the -th word. It will not be displayed anywhere else.
-
The width of each line does not exceed . Here, the width of a line refers to the distance from the left end of the leftmost word to the right end of the rightmost word.
When Takahashi displayed the sentence in the window, the sentence fit into or fewer lines. Find the minimum possible width of the window.
Input
The input is given from Standard Input in the following format:
$N$ $M$
$L _ 1$ $L _ 2$ $\ldots$ $L _ N$
Output
Print the answer in one line.
Example
13 3
9 5 2 7 1 8 8 2 1 5 2 3 6
26
Note
-
Constraints:
-
-
-
All input values are integers.
-
Source: ABC319D