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 product

def main():
    n, k = [int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    res = 10e10
    for t in product([0,1], repeat=n):
        if sum(t) < k:
            continue
        a_tmp = list(a)
        score = 0
        t_height = 0
        cnt = 0
        for i, h in enumerate(a_tmp):
            if t_height < h:
                t_height = h
                cnt += 1
            elif t[i]:
                t_height += 1
                score += t_height - h
            if cnt >= k:
                break
        res = min(res, score)
    print(res)
if __name__ == '__main__':
    main()

