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
from itertools import combinations

n, k = map(int, input().split())
a = [int(i) for i in input().split()]  #;print(a)
bar = [0] * n
for i in range(1, n):
    bar[i] = max(a[i-1], bar[i-1])
#print(bar)  

ans = float('inf')
for idx in combinations(range(1, n), k-1):
    x0 = a[0] ;dif = 0
    #print(idx)
    for i in range(k-1):
        if x0 < bar[idx[i]]:
            x0 = bar[idx[i]] #break   #    x0 = bar[i]
        if a[idx[i]] > x0:
            x0 = a[idx[i]]
        else:
            dif += x0 - a[idx[i]] + 1
            x0 = x0 + 1
    ans = min(ans, dif)
print(ans)    