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
import sys
readline = sys.stdin.readline

# 制約が小さいので、「見えてほしい建物」を全探索できる

N,K = map(int,readline().split())
A = list(map(int,readline().split()))

ans = 10 ** 13
for i in range(2 ** N):
  case = bin(i)[2:].zfill(N)
  if case.count("1") < K:
    continue
  # 前から順に見ていって、それまでで一番大きい建物の高さを記録
  # 選ばれた建物が、それまでで一番大きい建物の高さ + 1の高さになるように金額を計算
  # その最小値を求める
  cost = 0
  high = 0
  for j in range(N):
    # j番目の建物は選ぶ対象か？
    if (i >> j) & 1:
      if high >= A[j]:
        high += 1
        cost += (high - A[j])
    high = max(A[j], high)
  if ans > cost:
    ans = cost
print(ans)