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.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
 
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 ARTHUR_LOCAL
	#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
	const int MXN=100;
#else
	#define debug(x...)
	const int MXN=500000;
#endif

using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

int mini[MXN];
vector<int> tailed[MXN];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,k;
	cin>>n>>k;
	vector<int> L(n);
	for(int i=0; i<n; i++) cin>>L[i];
	sort(all(L));

	mini[0]=1;

	for(int d=0; d<MXN; d++){

		debug(d);
		debug(mini[d]);
		debug(len(tailed[d]));
		debug(mini[d+1]);
		// debug

		if(mini[d] + len(tailed[d]) >= k){
			cout<<d<<"\n";
			return 0;
		}

		if(mini[d] + 2*len(tailed[d]) + len(tailed[d+1]) + mini[d+1] >= k){
			cout<<d+1<<"\n";
			return 0;
		}

		while(!L.empty() && (mini[d]>0 || !tailed[d].empty())){
			int curl = L.back();
			L.pop_back();

			int curtail; 
			
			if(!tailed[d].empty()){
				curtail=tailed[d].back();
				tailed[d].pop_back();
			}

			else{
				curtail=1;
				mini[d]--;
			}

			if(curtail>2) tailed[d+1].push_back(curtail-1);
			if(curtail==2) mini[d+1]++;

			int l1 = int(curl/2);
			int l2 = int(curl/2) - int(curl%2==0);

			// cout<<l1<<" "<<l2<<endl;
			debug(l1);
			debug(l2);
			
			if(l1!=1) tailed[d+2].push_back(l1);
			else mini[d+2]++;

			if(l2!=1) tailed[d+2].push_back(l2);
			else mini[d+2]++;
		}
		// while(!L.empty()

		if(L.empty()){
		
			debug(mini[3]);

			int cur=len(tailed[d]) + mini[d];
			priority_queue<int> last_laugh;
			int carry=0;
			while(!tailed[d].empty()){
				last_laugh.push(-(tailed[d].back()+d-1));
				carry++;
				tailed[d].pop_back();
			}

			debug(carry);

			for(int e=d+1; e<MXN; e++){
				
				debug(e);

				cur+=len(tailed[e]) + mini[e];
				cur+=carry;

				debug(cur);

				while(!last_laugh.empty()&&-last_laugh.top()==e){
					carry--;
					last_laugh.pop();
				}

				while(!tailed[e].empty()){
					last_laugh.push(-(tailed[e].back()+e-1));
					carry++;
					tailed[e].pop_back();
				}

				if(cur >= k){
					cout<<e<<"\n";
					return 0;
				}
			}

			cout<<-1<<"\n";
			return 0;
		}
	}
}