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 <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1e12;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	ll ans = INF;
	for (int i = 0; i < (1 << N); i++) {
		vector<bool> used(N, false);
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) used[j] = true;
		}

		ll pre = 0;
		int cnt = 0;
		ll tmp = 0;
		for (int j = 0; j < N; j++) {
			if (used[j]) {
				pre++;
				pre = max(pre, a[j]);
				tmp += pre - a[j];
				cnt++;
			} else {
				cnt += (pre < a[j]);
				pre = max(pre, a[j]);
			}
		}
		if (cnt >= K) ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}