K blocks#7473

K blocks

1 second
64 megabytes
Hard

You are given a sequence of positive integers. Let's define the "value of a splitting" of the sequence into blocks as the sum of maximums in each of the blocks. For a given , find the minimal possible value of a splitting.

Input

First line contains two integers and (1 \le n \le 10^5, 1 \le k \le \min(n, 100)). Next line contains integers A_1, A_2, \ldots, A_n (1 \le A_i \le 10^6) - the sequence elements.

Output

Output one number - minimal possible value of a splitting.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading