/*
Author:DO MINH TUAN-LTT High School for Gifted Student
                ENJOY MY CODE :)
*/
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,k;
int h[N],f[N];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++) 
    {
        cin>>h[i];
    }
    sort(h+1,h+1+n,greater<int>());
    int s=0;
    f[0]=1,f[1]=-1;
    for(int i=0,pos=1;i<N-1;i++)
    {
        s+=f[i], f[i+1]+=f[i];
        if(s+f[i+1]>=k) return cout<<i+1,0;
        while(f[i]&&pos<=n)
        {
            int l=h[pos]/2,r=(h[pos]-1)/2;
            f[i]--,s--;
            f[i+2]+=2,
            f[i+2+l]--,f[i+2+r]--;
            pos++;
        }
    }
    cout<<-1;
    return 0;
}