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>
#include <string.h>
#include <vector>
using namespace std;
int N,K;
const long long INF=100000000000LL;
long long a[20];
long long reg(int n,int k,long long t){
	if(k==K)return 0;
	if(n==N)return INF;
	if(a[n]>t)return reg(n+1,k+1,a[n]);
	long long was=INF;
	was=min(was,t+1-a[n]+reg(n+1,k+1,t+1));
	was=min(was,reg(n+1,k,t));
	//cout<<n<<" "<<k<<" "<<t<<" "<<was<<endl;
	return was;
}
int main(){
//	memset(dp,-1,sizeof(dp));
	cin>>N>>K;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	cout<<reg(1,1,a[0])<<endl;
	return 0;
}
