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>
using namespace std;

int main(){ 
  int N, K;
  vector<int64_t> A(20), highest(20, 0);

  cin >> N >> K;
  for(int i=1; i<=N; i++){
    cin >> A[i];
    highest[i] = max(highest[i-1], A[i]);
  }

  int64_t ans = 1e15;
  for(int bits=0; bits<(1<<N); bits++){
    if(bitset<20>(bits).count() != K) continue;

    vector<int64_t> B = highest; int64_t cur = 0;
    for(int i=1; i<=N; i++){
      if(bits >> (i-1) & 1){
        if(A[i] <= B[i-1]){
          cur += B[i-1]-A[i]+1;
          B[i] = B[i-1]+1;
        }
      } else {
        B[i] = max(B[i-1], A[i]);
      } 
    }
    ans = min(ans, cur);
  }
  cout << ans << endl;
}