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;

typedef long long ll;
typedef pair<int, int> pii;

int n, k;
ll a[100];
ll ans = 1e18;
void dfs(int cur, ll hight, ll cost, int used) {
    if (used == k) {
        ans = min(ans, cost);
        return;
    }
    if (cur ==  n) {
        return ;
    }
    ll h;
    ll add = 0;
    if (a[cur] > hight) {
        h = a[cur];
    } else {
        h = hight + 1;
        add = h - a[cur];
    }
    
    hight = max(hight, a[cur]);
    dfs(cur + 1, h, cost + add, used + 1);
    dfs(cur + 1, hight, cost, used);
}

int main() {
    cin >> n >> k;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    dfs(1, a[0], 0, 1);
    cout << ans << endl;
    
    return 0;
}