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;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const ll INF = 1e18;

signed main() {
  int n,k;
  int a[15];
  cin >> n >> k;
  rep(i,n) cin >> a[i];

  ll ans = INF;
  rep(b, 1<<n) {
    if(__builtin_popcountll(b) != k) continue;
    ll s = 0;
    int maxh = 0;
    rep(i, n) {
      if ((b & 1<<i) && (maxh >= a[i])) {
        s += maxh - a[i] + 1;
        maxh++;
      }
      maxh = max(maxh, a[i]);
    }
    ans = min(ans, s);
  }
  cout << ans << endl;

}
