// 1469F
// Power Sockets

// I wanted to write 10 segtrees before tst
// I ended up writing only 1 (inefficient) segtree
// (yes, I know there is a O(n) solution but I'm too lazy to find a problem that actually requires segtree)

// I did it (in 90 minutes) but without cp-algorithms :D
// now I will get runtime error on test 6

// it's range sum, not range min :/

#include <bits/stdc++.h>
using namespace std;

#define nl "\n"
#define nf endl
#define ll long long
#define pb push_back
#define _ << ' ' <<

#define INF (ll)1e18
#define mod 998244353
#define maxn 200010
#define ub 200110
#define maxs 1050000

ll i, i1, j, k, k1, t, n, m, res, flag[10], a[maxn], b;
ll st[maxs], lz[maxs];

void push(ll p, ll tl, ll tr) {
    ll k = lz[p];
    lz[p] = 0;
    if (2 * p + 1 >= maxs) return;
    ll tm = (tl + tr) / 2;
    st[2 * p] += k * (tm - tl + 1); st[2 * p + 1] += k * (tr - tm);
    lz[2 * p] += k; lz[2 * p + 1] += k;
}

/*
p = current node in st
[tl, tr] = interval of p
[l, r] = interval of query inside p
x = value to add
*/

void upd(ll p, ll tl, ll tr, ll l, ll r, ll x) {
    // cout << "upd " << p _ tl _ tr _ l _ r _ x << nl;
    if (l > r) return;
    push(p, tl, tr);
    if (tl == l && tr == r) {
        st[p] += x * (tr - tl + 1); lz[p] += x; return;
    }
    ll tm = (tl + tr) / 2;
    upd(2 * p, tl, tm, l, min(tm, r), x);
    upd(2 * p + 1, tm + 1, tr, max(tm + 1, l), r, x);
    st[p] = st[2 * p] + st[2 * p + 1];
}

ll rsq(ll p, ll tl, ll tr, ll l, ll r) {
    // cout << "rsq " << p _ tl _ tr _ l _ r << nl;
    if (l > r) return 0;
    push(p, tl, tr);
    // cout << st[p] << nl;
    if (tl == l && tr == r) return st[p];
    ll tm = (tl + tr) / 2;
    return rsq(2 * p, tl, tm, l, min(tm, r)) +
    rsq(2 * p + 1, tm + 1, tr, max(tm + 1, l), r);
}

ll bs() {
    ll bsl, bsm, bsu;
    bsl = 0; bsu = ub;
    while (bsl != bsu) {
        bsm = (bsl + bsu) / 2;
        // cout << bsm _ rsq(1, 0, n + 100, 0, bsm) << nl;
        if (rsq(1, 0, ub, 0, bsm) >= k) bsu = bsm;
        else bsl = bsm + 1;
    }
    return bsl;
}

void cln() {
    ll i;
    for (i = 0; i <= ub; i++) upd(1, 0, ub, i, i, 0);
}

void dbg() {
    cln();
    for (ll i = 0; i <= 10; i++) {
        cout << rsq(1, 0, ub, i, i) << ' ';
    }
    cout << nl;
    /* for (ll i = 0; i <= 150; i++) cout << st[i] << ' ';
    cout << nl; */
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    #if !ONLINE_JUDGE && !EVAL
        ifstream cin("input.txt");
        ofstream cout("output.txt");
    #endif

    cin >> n >> k; res = ub;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }

    sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1);

    upd(1, 0, ub, 0, 0, 1);
    for (i = 1; i <= n; i++) {
        while (rsq(1, 0, ub, m, m) == 0) m++;
        upd(1, 0, ub, m, m, -1);
        upd(1, 0, ub, m + 2, m + ((a[i] + 1) / 2), 2);
        if (a[i] % 2 == 0) {
            upd(1, 0, ub, m + ((a[i] + 2) / 2), m + ((a[i] + 2) / 2), 1);
        }
        // dbg();
        res = min(res, bs());
    }

    if (res == ub) cout << -1 << nl;
    else cout << res << nl;

    return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

// We decided to drop the legend about the power sockets but feel free to come up with your own :^)

Define a chain: 

  * a chain of length 1 is a single vertex; 
  * a chain of length x is a chain of length x-1 with a new vertex connected to the end of it with a single edge. 



You are given n chains of lengths l_1, l_2, ..., l_n. You plan to build a tree using some of them.

  * Each vertex of the tree is either white or black. 
  * The tree initially only has a white root vertex. 
  * All chains initially consist only of white vertices. 
  * You can take one of the chains and connect any of its vertices to any white vertex of the tree with an edge. The chain becomes part of the tree. Both endpoints of this edge become black. 
  * Each chain can be used no more than once. 
  * Some chains can be left unused. 



The distance between two vertices of the tree is the number of edges on the shortest path between them.

If there is at least k white vertices in the resulting tree, then the value of the tree is the distance between the root and the k-th closest white vertex.

What's the minimum value of the tree you can obtain? If there is no way to build a tree with at least k white vertices, then print -1.

Input

The first line contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 2 ≤ k ≤ 10^9) — the number of chains and the minimum number of white vertices a tree should have to have a value.

The second line contains n integers l_1, l_2, ..., l_n (3 ≤ l_i ≤ 2 ⋅ 10^5) — the lengths of the chains.

Output

Print a single integer. If there is no way to build a tree with at least k white vertices, then print -1. Otherwise, print the minimum value the tree can have.

Examples

Input


1 2
3


Output


2


Input


3 3
4 3 3


Output


3


Input


3 5
4 3 4


Output


4


Input


2 10
5 7


Output


-1

Note

<image>

You are allowed to not use all the chains, so it's optimal to only use chain of length 4 in the second example.

### Response

```cpp
// 1469F
// Power Sockets

// I wanted to write 10 segtrees before tst
// I ended up writing only 1 (inefficient) segtree
// (yes, I know there is a O(n) solution but I'm too lazy to find a problem that actually requires segtree)

// I did it (in 90 minutes) but without cp-algorithms :D
// now I will get runtime error on test 6

// it's range sum, not range min :/

#include <bits/stdc++.h>
using namespace std;

#define nl "\n"
#define nf endl
#define ll long long
#define pb push_back
#define _ << ' ' <<

#define INF (ll)1e18
#define mod 998244353
#define maxn 200010
#define ub 200110
#define maxs 1050000

ll i, i1, j, k, k1, t, n, m, res, flag[10], a[maxn], b;
ll st[maxs], lz[maxs];

void push(ll p, ll tl, ll tr) {
    ll k = lz[p];
    lz[p] = 0;
    if (2 * p + 1 >= maxs) return;
    ll tm = (tl + tr) / 2;
    st[2 * p] += k * (tm - tl + 1); st[2 * p + 1] += k * (tr - tm);
    lz[2 * p] += k; lz[2 * p + 1] += k;
}

/*
p = current node in st
[tl, tr] = interval of p
[l, r] = interval of query inside p
x = value to add
*/

void upd(ll p, ll tl, ll tr, ll l, ll r, ll x) {
    // cout << "upd " << p _ tl _ tr _ l _ r _ x << nl;
    if (l > r) return;
    push(p, tl, tr);
    if (tl == l && tr == r) {
        st[p] += x * (tr - tl + 1); lz[p] += x; return;
    }
    ll tm = (tl + tr) / 2;
    upd(2 * p, tl, tm, l, min(tm, r), x);
    upd(2 * p + 1, tm + 1, tr, max(tm + 1, l), r, x);
    st[p] = st[2 * p] + st[2 * p + 1];
}

ll rsq(ll p, ll tl, ll tr, ll l, ll r) {
    // cout << "rsq " << p _ tl _ tr _ l _ r << nl;
    if (l > r) return 0;
    push(p, tl, tr);
    // cout << st[p] << nl;
    if (tl == l && tr == r) return st[p];
    ll tm = (tl + tr) / 2;
    return rsq(2 * p, tl, tm, l, min(tm, r)) +
    rsq(2 * p + 1, tm + 1, tr, max(tm + 1, l), r);
}

ll bs() {
    ll bsl, bsm, bsu;
    bsl = 0; bsu = ub;
    while (bsl != bsu) {
        bsm = (bsl + bsu) / 2;
        // cout << bsm _ rsq(1, 0, n + 100, 0, bsm) << nl;
        if (rsq(1, 0, ub, 0, bsm) >= k) bsu = bsm;
        else bsl = bsm + 1;
    }
    return bsl;
}

void cln() {
    ll i;
    for (i = 0; i <= ub; i++) upd(1, 0, ub, i, i, 0);
}

void dbg() {
    cln();
    for (ll i = 0; i <= 10; i++) {
        cout << rsq(1, 0, ub, i, i) << ' ';
    }
    cout << nl;
    /* for (ll i = 0; i <= 150; i++) cout << st[i] << ' ';
    cout << nl; */
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    #if !ONLINE_JUDGE && !EVAL
        ifstream cin("input.txt");
        ofstream cout("output.txt");
    #endif

    cin >> n >> k; res = ub;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }

    sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1);

    upd(1, 0, ub, 0, 0, 1);
    for (i = 1; i <= n; i++) {
        while (rsq(1, 0, ub, m, m) == 0) m++;
        upd(1, 0, ub, m, m, -1);
        upd(1, 0, ub, m + 2, m + ((a[i] + 1) / 2), 2);
        if (a[i] % 2 == 0) {
            upd(1, 0, ub, m + ((a[i] + 2) / 2), m + ((a[i] + 2) / 2), 1);
        }
        // dbg();
        res = min(res, bs());
    }

    if (res == ub) cout << -1 << nl;
    else cout << res << nl;

    return 0;
}

```