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 <map>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define INF (1LL<<60)
typedef long long ll;

int N, K;
ll a[16];
map<pair<ll, pair<int, int> >, int>dp;

ll dfs(ll h, int n, int k){
  if(k == 0) return 0;
  if(n == N) return INF;
  ll res = INF;
  pair<ll, pair<int, int> >P = make_pair(h, make_pair(n, k));; 
  //  if(dp.find(P) != dp.end()){
  //    return dp[P];
  //  }

  if(N-n > k){
    res = min(res, dfs(max(h, a[n]), n+1, k));
  }
  res = min(res, dfs(a[n] + max(h-a[n]+1, 0LL), n+1, k-1) + max(h-a[n]+1, 0LL));
  //  cout << h << " " << n << " " << k << " " << res << endl;  
  dp[P] = res;
  return res;
}

int main(){
  cin >> N >> K;
  for(int i=0;i<N;i++) cin >> a[i];
  
  cout << dfs(0, 0, K) << endl;
  return 0;
}
