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 <cstdio>
#include <algorithm>
#include <cstring>

#define maxn 20
int a[maxn], b[maxn];
typedef long long ll;
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
int main()
{
	int n, k; scanf("%d%d", &n, &k);
	ll ans = ~0ULL >> 1;
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
	for (int S = 0, _ = 1 << n; S < _; ++S)
	{
		memcpy(b, a, n << 2);
		int cnt = 0;
		ll cost = 0, maxx = -0x7fffffff;
		for (int i = 0; i < n; ++i)
		{
			if ((S & (1 << i)) && b[i] <= maxx)
				cost += maxx - b[i] + 1, b[i] = maxx + 1;
			cmax(maxx, b[i]) ? ++cnt : 0;
		}
		cnt >= k ? cmin(ans, cost) : 0;
	}
	printf("%lld\n", ans);
	return 0;
}