#BS0000022. Rót đầy các thùng chứa (Fill the Containers)

Rót đầy các thùng chứa (Fill the Containers)

Fill the Containers

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn vessels in a fixed conveyor-belt order, and vessel ii contains cic_i units of milk. All milk from one vessel must be poured into exactly one container; a vessel may not be split between containers.

Number the mm containers from 11 to mm. The vessel order must be preserved: if vessel ii comes before vessel jj, and they are poured into containers rr and ss, respectively, then

r≤s.r\le s.

Thus, the vessels assigned to each used container form a contiguous segment of the original sequence. Some containers may remain unused.

The containers do not have to have the same capacity. Each container may be assigned its own capacity. Minimize the largest capacity among the used containers. Equivalently, find the smallest CC such that all milk can be transferred in order using at most mm containers and the total milk poured into every used container is at most CC.

Input

The first line contains n,mn,m. The second line contains c1,…,cnc_1,\ldots,c_n.

Output

Print the minimum possible value of the maximum container capacity.

Subtasks

  • Subtask 1 — 20%: m=1m=1 or m≥nm\ge n.
  • Subtask 2 — 30%: 1≤n≤1001\le n\le100.
  • Subtask 3 — 50%: 1≤n≤10001\le n\le1000, 1≤m≤1061\le m\le10^6, 1≤ci≤1061\le c_i\le10^6.

Examples

Input

5 3
1 2 3 4 5

Output

6

Explanation

The groups [1,2,3][1,2,3], [4][4], and [5][5] require maximum capacity 66, which is optimal.