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 <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k;
int a[15];

signed main() {
	int i, j;
	
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	
	int INF = 1e+15;
	int ans = INF;
	rep(i, (1 << n)) {
		int cnt = 0;
		rep(j, n) if ((i >> j) % 2 == 1) cnt++;
		if (cnt < k) continue;
		
		int maxH = 0;
		int sumC = 0;
		rep(j, n) {
			if ((i >> j) % 2 == 1) {
				sumC += max(maxH + 1, a[j]) - a[j];
				maxH = max(maxH + 1, a[j]);
			}
			else {
				maxH = max(maxH, a[j]);
			}
		}
		ans = min(ans, sumC);
	}
	cout << ans << endl;
	return 0;
}