Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.

Thus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.

The profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\max\limits_{l \le i \le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.

You want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.

For example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2000$) — the number of problems and the number of days, respectively.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).
8 3
5 4 2 6 5 1 9 2
20
4 1 3
5 1
1 1 1 1 1
1
5
4 2
1 2000 2000 2
4000
2 2
1 1
2000
2000
1
1 1
1234
1234
1
3 2
1 1 1
2
2 1
4 2
3 5 1 1
8
1 3
5 3
5 5 6 7 1
18
2 1 2
6 4
1 1 1 1 2 2
6
3 1 1 1
5 3
5 5 6 6 4
17
2 1 2
16 15
14 4 9 12 17 1 1 8 12 13 6 9 17 2 18 12
154
1 1 1 1 1 2 1 1 1 1 1 1 1 1 1
1 1
1996
1996
1
5 3
5 5 5 9 10
24
3 1 1
18 15
18 2 13 1 18 3 2 18 18 20 9 2 20 20 4 20 9 12
204
1 2 2 1 2 1 1 1 1 1 1 1 1 1 1
5 3
1 20 20 50 50
120
3 1 1
8 3
15 14 11 19 17 14 14 8
51
1 3 4
5 2
15 20 6 19 6
39
2 3
6 3
5 5 5 5 6 9
20
4 1 1
5 3
2 2 2 3 3
8
3 1 1
7 3
2 2 2 2 2 3 3
8
5 1 1
6 5
1 1 6 6 6 6
25
2 1 1 1 1
8 4
1 2 2 2 2 3 4 5
14
5 1 1 1
6 4
1 1 1 5 5 5
16
3 1 1 1
6 3
1 2 2 2 4 5
11
4 1 1
18 6
17 17 19 14 10 20 18 16 6 7 2 15 14 16 13 6 12 11
107
1 1 1 3 1 11
6 3
1 1 2 2 3 4
9
4 1 1
8 3
5 4 2 5 6 1 9 2
20
4 1 3
def main():
    n, k = map(int, input().split())
    arr = list(map(int, input().split()))
    sorted_arr_max = list(sorted(arr))[-k:]

    temp_dict = {}
    for element in sorted_arr_max:
        if element in temp_dict:
            temp_dict[element] += 1
        else:
            temp_dict[element] = 1

    max_indices = []
    for i in range(n):
        if arr[i] in temp_dict and temp_dict[arr[i]] > 0:
            max_indices.append(i)
            temp_dict[arr[i]] -= 1

    answer_arr = [max_indices[0] + 1]
    for i in range(1, len(max_indices) - 1):
        answer_arr.append(max_indices[i] - max_indices[i - 1])
    if len(max_indices) > 1:
        answer_arr.append(n - sum(answer_arr))

    print(sum(sorted_arr_max))
    print(*answer_arr)


if __name__ == "__main__":
    main()

# suppose the largest elements [2,2,3,3], it will give bugs when finding the index of these.
