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
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int lli;

const lli maxn = 16, inf = lli(1e17)+5;

lli A[maxn], maxi[maxn];

int main(void)
{
	lli n, k;
	scanf("%lld%lld", &n, &k);
	for(lli i = 0;i < n;i++) scanf("%lld", &A[i]);

	for(lli i = 0;i < n;i++)
	{
		maxi[i] = max(maxi[i], A[i]);
		if(i) maxi[i] = max(maxi[i], maxi[i-1]);
	}

	lli res = inf;
	for(lli mask = 0;mask < (1<<n);mask++)
	{
		if(__builtin_popcount(mask) == k)
		{
			lli cost = 0, maxiyet = -1;
			for(lli i = 0;i < n;i++)
			{
				if(mask&(1<<i))
				{
					lli newht = maxiyet+1;
					if(i) newht = max(maxi[i-1]+1, newht);
					cost += max(0ll, newht-A[i]);
					maxiyet = newht;
				}
			}
			res = min(res, cost);
		}
	}
	printf("%lld\n", res);
}