#BS0000021. Chia mảng (Array Division)

Chia mảng (Array Division)

Array Division

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array of nn positive integers, divide it into exactly kk non-empty contiguous subarrays covering the whole array. If the sum of subarray jj is SjS_j, minimize

max⁡1≤j≤kSj.\max_{1\le j\le k} S_j.

Input

The first line contains n,kn,k. The second line contains x1,…,xnx_1,\ldots,x_n.

Output

Print the minimum possible value of the maximum subarray sum.

Subtasks

  • Subtask 1 — 20%: k=1k=1 or k=nk=n.
  • Subtask 2 — 30%: 1≤n≤20001\le n\le2000.
  • Subtask 3 — 50%: 1≤n≤2⋅1051\le n\le2\cdot10^5, 1≤k≤n1\le k\le n, 1≤xi≤1091\le x_i\le10^9.

Examples

Input

5 3
2 4 7 3 5

Output

8

Explanation

An optimal division is [2,4],[7],[3,5][2,4],[7],[3,5], whose maximum sum is 88.