Text is a sequence of words, and a word consists of characters. Your task is to put words into a grid with W columns and sufficiently many lines. For the beauty of the layout, the following conditions have to be satisfied.
Figure I.1: A good layout.
Figure I.2: BAD | Do not reorder words.
Figure I.3: BAD | Words must be separated by spaces.
Figure I.4: BAD | Characters in a single word must be contiguous.
Figure I.5: BAD | Lines must be justied to both the left and the right sides.
The text is the most beautifully laid out when there is no unnecessarily long spaces. For instance, the layout in Figure I.6 has at most 2 contiguous spaces, which is more beautiful than that in Figure I.1, having 3 contiguous spaces. Given an input text and the number of columns, please find a layout such that the length of the longest contiguous spaces between words is minimum.
Figure I.6: A good and the most beautiful layout.
The input consists of multiple datasets, each in the following format.
x1 x2 ... xN
W, N, and xi are all integers. W is the number of columns (3 ≤ W ≤ 80,000). N is the number of words (2 ≤ N ≤ 50,000). xi is the number of characters in the i-th word (1 ≤ xi ≤ (W−1)/2 ). Note that the upper bound on xi assures that there always exists a layout satisfying the conditions.
The last dataset is followed by a line containing two zeros.
For each dataset, print the smallest possible number of the longest contiguous spaces between words.
11 4 4 2 1 3 5 7 1 1 1 2 2 1 2 11 7 3 1 3 1 3 3 4 100 3 30 30 39 30 3 2 5 3 0 0
2 1 2 40 1