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
#winners never quit, quiters never win
from collections import deque as de
import math
from collections import Counter as cnt
class My_stack():
    def __init__(self):
        self.data = []
    def my_push(self, x):
        return (self.data.append(x))
    def my_pop(self):
        return (self.data.pop())
    def my_peak(self):
        return (self.data[-1])
    def my_contains(self, x):
        return (self.data.count(x))
    def my_show_all(self):
        return (self.data)
    def isEmpty(self):
      return len(self.data)==0

arrStack = My_stack()    
# A optimized school method based 
# Python3 program to check 
# if a number is prime 


def isPrime(n) : 

	# Corner cases 
	if (n <= 1) : 
		return False
	if (n <= 3) : 
		return True

	# This is checked so that we can skip 
	# middle five numbers in below loop 
	if (n % 2 == 0 or n % 3 == 0) : 
		return False

	i = 5
	while(i * i <= n) : 
		if (n % i == 0 or n % (i + 2) == 0) : 
			return False
		i = i + 6

	return True

def get_prime_factors(number):
    # create an empty list and later I will
    # run a for loop with range() function using the append() method to add elements to the list.
    prime_factors = []

    # First get the number of two's that divide number
    # i.e the number of 2's that are in the factors
    while number % 2 == 0:
        prime_factors.append(2)
        number = number / 2

    # After the above while loop, when number has been
    # divided by all the 2's - so the number must be odd at this point
    # Otherwise it would be perfectly divisible by 2 another time
    # so now that its odd I can skip 2 ( i = i + 2) for each increment
    for i in range(3, int(math.sqrt(number)) + 1, 2):
        while number % i == 0:
            prime_factors.append(int(i))
            number = number / i


    # Here is the crucial part.
    # First quick refreshment on the two key mathematical conjectures of Prime factorization of any non-Prime number
    # Which is - 1. If n is not a prime number AT-LEAST one Prime factor would be less than sqrt(n)
    # And - 2. If n is not a prime number - There can be AT-MOST 1 prime factor of n greater than sqrt(n).
    # Like 7 is a prime-factor for 14 which is greater than sqrt(14)
    # But if the above loop DOES NOT go beyond square root of the initial n.
    # Then how does that greater than sqrt(n) prime-factor
    # will be captured in my prime factorization function.
    # ANS to that is - in my first for-loop I am dividing n with the prime number if that prime is a factor of n.
    # Meaning, after this first for-loop gets executed completely, the adjusted initial n should become
    # either 1 or greater than 1
    # And if n has NOT become 1 after the previous for-loop, that means that
    # The remaining n is that prime factor which is greater that the square root of initial n.
    # And that's why in the next part of my algorithm, I need to check whether n becomes 1 or not,
    #This code is taken by rohan paul's github
    if number > 2:
        prime_factors.append(int(number))

    return prime_factors
def get_frequency(list):
    dic={}
    for ele in list:
        if ele in dic:
            dic[ele] += 1
        else:
            dic[ele] = 1
    return dic
#here we go......................
#winners never quit, quitters never win
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=sorted(a, reverse=True)
dic={}
totalprofit=0
for i in range(k):
    totalprofit+=l[i]
    if l[i] in dic:
        dic[l[i]]+=1
    else:
        dic[l[i]]=1
ans=[]
count=0
for i in range(n):
    if a[i] in dic:
        count+=1
        if dic[a[i]]==1:
            del dic[a[i]]
        else:
            dic[a[i]]-=1
        if not dic:
            count-=1
            ans.append(count+ n-i)
            break
        else:
            ans.append(count)
        count=0
    else:
        count+=1
print(totalprofit)
print(*ans) 

