Round Table

Time Limit : 8 sec, Memory Limit : 65536 KB

Problem H: Round Table

You are the owner of a restaurant, and you are serving for N customers seating in a round table.

You will distribute M menus to them. Each customer receiving a menu will make the order of plates, and then pass the menu to the customer on the right unless he or she has not make the order. The customer i takes Li unit time for the ordering.

Your job is to write a program to calculate the minimum time until all customers to call their orders, so you can improve your business performance.


The input consists of a sequence of positive integers.

The first line of the input contains two positive integers N (N ≤ 50,000) and M (MN). The second line contains N positive integers L1, L2,..., LN (Li ≤ 600).


Output the minimum possible time required for them to finish ordering.

Sample Input and Output

Input #1

3 2
1 5 10

Output #1


Input #2

4 2
1 2 3 4

Output #2


Source: ACM-ICPC Japan Alumni Group Winter Camp , Day 3, Tokyo, Japan, 2009-02-23