#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<bitset>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
using namespace std;

typedef long long ll;

const int maxn=2100040;
const ll mod=1e9+7;

ll n,k;
ll len[maxn];
ll dep[maxn];

bool cmp(ll x,ll y)
{
	return x>y;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	ll sum=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&len[i]);
		sum+=(len[i]-2);
	}
	if(sum<k)
	{
		printf("-1");
		return 0;
	}
	sort(len+1,len+n+1,cmp);
	//for(int i=1;i<=9;i++) printf("%d ",len[i]);
	//printf("\n");
	dep[0]=1;
	ll j=1;
	dep[1]=-1;
	sum=0;
	ll del=0;
	for(int i=0;;i++)
	{
		sum+=dep[i];
		//printf("%lld %lld %lld %lld\n",sum+sum+dep[i+1],sum,dep[i],dep[i+1]);
		if(del+sum+sum+dep[i+1]>=k)
		{
			printf("%d\n",i+1);
			break;
		}
		ll tag=sum;
		while(tag&&j<=n)
		{
			tag--;
			ll x=len[j]-1;
			dep[i+2]+=2;
			dep[i+2+x/2]--;
			dep[i+2+x-x/2]--;
			j++;
		}
		del+=tag;
	}
	return 0;
}