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>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MAX_N=15;
const ll INF=1e18;	
using namespace std;
int N,K;
ll a[MAX_N];
int main(){
	cin>>N>>K;
	REP(i,N)cin>>a[i];
	ll ans=INF;
	REP(bit,1<<(N-1)){
		int cnt=1;
		ll h=a[0],sm=0;
		REP(j,N-1){
			if((bit>>j)&1){
				sm+=max(h+1-a[j+1],0ll);
				cnt++;
				h=max(a[j+1],h+1);
			}else{
				h=max(a[j+1],h);
			}
			
		}
		if(cnt>=K){
			ans=min(ans,sm);
		}
	}
	cout<<ans<<endl;
}