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 <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	vector<long long> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}

	long long ans = LLONG_MAX;
	for (int bit = 0;bit < (1 << n);bit++) {

		long long max = a[0];
		long long tmp = 0;
		int count = 1;
		for (int i = 1;i < n;i++) {
			if (bit & (1 << i)) {
				if (max >= a[i]) {
					tmp += max + 1 - a[i];
					max++;
					count++;
				}
			}
			if (max < a[i]) {
				max = a[i];
				count++;
			}
		}

		if (count >= k) {
			if (ans > tmp) ans = tmp;
		}
	}

	cout << ans << endl;
	return 0;
}
