//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    sort(l.rbegin(), l.rend());
    const int N=5e5;
    vector<int> a(N);
    a[0]=1,a[1]=-1;
    int ans=1e9;
    int sum=0;
    for(int i=0,j=0;i<N-1;i++){
        sum+=a[i];
        a[i+1]+=a[i];
        if(sum+a[i+1]>=k){
            ans=i+1; break;
        }
        while(a[i]>0 and j<n){
            int u=(l[j]-1)/2;
            int v=l[j]-1-u;
            a[i+2]++;
            a[i+2+u]--;
            a[i+2]++;
            a[i+2+v]--;
            a[i]--;
            sum--;
            j++;
        }
    }
    if(ans==1e9){
        ans=-1;
    }
    cout << ans << endl;
}