Input Format


N K
a_1 a_2 a_3 ... a_N


Output Format

Print the minimum cost in one line. In the end put a line break.


Constraints

* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9



Scoring

Subtask 1 [120 points]


* N = K

Subtask 2 [90 points]


* N ≤ 5
* a_i ≤ 7

Subtask 3 [140 points]


* There are no additional constraints.

Output Format

Print the minimum cost in one line. In the end put a line break.


Constraints

* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9



Scoring

Subtask 1 [120 points]


* N = K

Subtask 2 [90 points]


* N ≤ 5
* a_i ≤ 7

Subtask 3 [140 points]


* There are no additional constraints.

Input Format


N K
a_1 a_2 a_3 ... a_N

Example

Input

5 5
3949 3774 3598 3469 3424


Output

1541
N,K = map(int,input().split())
a = list(map(int, input().split()))

import itertools
import sys
list_n = itertools.combinations(range(N),K)
ans = 1000000000000000
for i_list in list_n:#i_list は見ることのできるようにする建物のインデックスのリスト
    a_i = a.copy()
    cost = 0
    for index in i_list:
        if not index == 0:
            m_index = max(a_i[:index])
        else:
            m_index = 0
        if m_index >= a_i[index]:
            cost += m_index - a_i[index] + 1
            #print(m_index - a_i[index] + 1)
            a_i[index] = a_i[index] + m_index - a_i[index] + 1   
    ans = min(ans, cost)
    
print(ans)