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
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()

a = li()
min_cost = float('inf')

for i in range(2**n):
    select = []
    a2 = a.copy()
    for j in range(n):
        if (i >> j)&1:
            select.append(j)

    if(len(select) != k):
        continue

    cost = 0
    b_max = a2[0]
    for j in range(1,n):
        if j in select:
            if(a2[j] <= b_max):
                cost += b_max+1 - a2[j]
                a2[j] = b_max+1
        b_max = max(b_max, a2[j])
    min_cost = min(min_cost, cost)

print(min_cost)