/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED 
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif
 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) 
 
#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
const ll INF = 9e18;
 
ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}
 
ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}
 
// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();
    
    ll n, k;
    cin >> n >> k;
    
    // adding new edges give n - 2 more white vertices
    // start with one white
    // add longer first (exchange arugments)
    // add to the shortest depth available (greedy)
    
    // How to cal ans?
    // Segtree binary search on min prefix with atleast k white
    // binary search of ans(proof ?) and calculate possible for each answer
    
    vl arr(n);
    fo(i, n) cin >> arr[i];
    
    sort(all(arr), greater<ll>());
    
    ll lo = 0, hi = 2e5;
    
    while(lo < hi) {
	ll mid = lo + (hi - lo)/2;
	
	ll total_white = 0;
	ll current_depth = 0;
	ll pre_sum_on_depth = 1;
	ll current_depth_count = 1;
	ll wvertices_less_mid = 1;
	bool can = false;
	ll upper, lower;
	vl depth_count(2e5, 0);
	
	depth_count[0] = 1;
	depth_count[1] = -1;
	 
	fo(i, n) {
	    while (current_depth_count == 0) {
		current_depth++;
		pre_sum_on_depth += depth_count[current_depth];
		current_depth_count = pre_sum_on_depth;
	    }
	    
	    if (current_depth > mid) break;
	    
	    current_depth_count--;
	    wvertices_less_mid--;
	    
	    total_white += arr[i] - 2;
	    depth_count[current_depth + 1]--;
	    depth_count[current_depth + 1]++;
	    
	    lower = current_depth + 2;
	    upper = current_depth + 2 + (arr[i] - 3)/2;
	    
	    depth_count[lower] += 2;
	    depth_count[upper + 1] -= 2;
	    
	    wvertices_less_mid += (min(mid, upper) - lower + 1) * 2;
	    
	    if (arr[i] % 2 == 0) {
		depth_count[upper + 1]++;
		depth_count[upper + 2]--;
		if (upper + 1 <= mid)
		    wvertices_less_mid++;
	    }
	    // check if kth closest white vertex is at depth mid or greater
	    if (wvertices_less_mid >= k) {
		can = true;
		break;
	    }
	}
	
	if (can) {
	    hi = mid;
	}else {
	    lo = mid + 1;
	}
    }
    
    cout << (hi != 2e5 ? hi : -1) << '\n';
    
    return 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

// 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
/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED 
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif
 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) 
 
#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
const ll INF = 9e18;
 
ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}
 
ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}
 
// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();
    
    ll n, k;
    cin >> n >> k;
    
    // adding new edges give n - 2 more white vertices
    // start with one white
    // add longer first (exchange arugments)
    // add to the shortest depth available (greedy)
    
    // How to cal ans?
    // Segtree binary search on min prefix with atleast k white
    // binary search of ans(proof ?) and calculate possible for each answer
    
    vl arr(n);
    fo(i, n) cin >> arr[i];
    
    sort(all(arr), greater<ll>());
    
    ll lo = 0, hi = 2e5;
    
    while(lo < hi) {
	ll mid = lo + (hi - lo)/2;
	
	ll total_white = 0;
	ll current_depth = 0;
	ll pre_sum_on_depth = 1;
	ll current_depth_count = 1;
	ll wvertices_less_mid = 1;
	bool can = false;
	ll upper, lower;
	vl depth_count(2e5, 0);
	
	depth_count[0] = 1;
	depth_count[1] = -1;
	 
	fo(i, n) {
	    while (current_depth_count == 0) {
		current_depth++;
		pre_sum_on_depth += depth_count[current_depth];
		current_depth_count = pre_sum_on_depth;
	    }
	    
	    if (current_depth > mid) break;
	    
	    current_depth_count--;
	    wvertices_less_mid--;
	    
	    total_white += arr[i] - 2;
	    depth_count[current_depth + 1]--;
	    depth_count[current_depth + 1]++;
	    
	    lower = current_depth + 2;
	    upper = current_depth + 2 + (arr[i] - 3)/2;
	    
	    depth_count[lower] += 2;
	    depth_count[upper + 1] -= 2;
	    
	    wvertices_less_mid += (min(mid, upper) - lower + 1) * 2;
	    
	    if (arr[i] % 2 == 0) {
		depth_count[upper + 1]++;
		depth_count[upper + 2]--;
		if (upper + 1 <= mid)
		    wvertices_less_mid++;
	    }
	    // check if kth closest white vertex is at depth mid or greater
	    if (wvertices_less_mid >= k) {
		can = true;
		break;
	    }
	}
	
	if (can) {
	    hi = mid;
	}else {
	    lo = mid + 1;
	}
    }
    
    cout << (hi != 2e5 ? hi : -1) << '\n';
    
    return 0;
}

```