#include<iostream>
#include<vector>
#include<cstring>
#include<unordered_map>
#include<math.h>
#include<map>
#include<algorithm>
#include<iomanip>
#include<stdio.h>
#include<set>
#include<queue>
#include<tuple>

using namespace std;

#define ll long long
#define int long long
typedef vector<ll> vi;
typedef pair<ll, ll>  ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
#define INF 1e9
#define INF64 (ll)1e18
#define pb push_back
#define F first
#define S second
#define MP make_pair
#define forn(i,l,r) for(ll i=l ; i<r ; i++)
void print(vi& a) {for(int i : a) cout<<i<<' '; cout<<endl;}
// int n;
// vi x,y,v;
// map<int, set<int> > xs, ys;
// map<ii, int> pos;

// void choose(int x, int y) {
//     int lx = -1;
//     auto left = lower_bound(ys[y].begin(), ys[y].end(), x[i]);
//     if(left == ys[i].begin());
//     else {
//         left--;
//         lx = *left;
//     }
//     int lL = pos[]
// }
// int n;
// vi a;
ll max(ll a, ll b) {return (a>b)?a:b;}
ll min(ll a, ll b) {return (a>b)?b:a;}
void countSort(int k, vector<int>& SA, vector<int>& eqC){
    int n = SA.size();
 
    int maxi = max(300, n);
    vector<int> count(maxi,0);
    for(int i=0;i<n;i++)
        count[i+k<n ? eqC[i+k] : 0]++;
    
    vector<int> pos(maxi,0);
    pos[0]=0;
    for(int i=1;i<maxi;i++)
        pos[i] = pos[i-1] + count[i-1];
    
    vector<int> tempSA(n,0);
    for(int i=0;i<n;i++)
        tempSA[pos[SA[i]+k<n?eqC[SA[i]+k]:0]++] = SA[i];
    
    for(int i=0;i<n;i++) SA[i]=tempSA[i];
}
 
vector<int> buildSA(string& t){
    t+='$';
 
    int n=t.length();
    vector<int> SA(n,0), eqC(n,0);
 
    for(int i=0;i<n;i++) SA[i]=i;
    for(int i=0;i<n;i++) eqC[i]=t[i];
 
    for(int k=1;k<n;k<<=1){ //logn
        countSort(k, SA, eqC); // n
        countSort(0,SA,eqC); // n
        
        vector<int> tempEqC(n, 0);
        int r = tempEqC[SA[0]] = 0;
        for(int i=1;i<n;i++){ // n
            if(eqC[SA[i]] == eqC[SA[i-1]] && eqC[SA[i]+k] == eqC[SA[i-1]+k])
                tempEqC[SA[i]] = r;
            else tempEqC[SA[i]] = ++r;
        }
        for(int i=0;i<n;i++) eqC[i] = tempEqC[i];
    }
    return SA;
}
vector<int> lcp(string txt, vector<int> SA) {
    int  i, L;
    int n = txt.length();
    vector<int> Phi(SA.size(), 0);
    Phi[SA[0]]=-1;
    for(int i=1;i<n;i++)
        Phi[SA[i]] = SA[i-1];
    vector<int> PLCP(SA.size(),0);
    for(i=L=0; i<n;i++){
        if(Phi[i]==-1){PLCP[i]=0; continue;}
        while(txt[i+L] == txt[Phi[i] + L]) L++;
        PLCP[i]=L;
        L=max(L-1,0);
    }
    vector<int> LCP(SA.size());
    for(i=0;i<n;i++)
        LCP[i]=PLCP[SA[i]];
    return LCP;
}  
const int N = 200010;
int n,k;
int l[N], diff[2*N + 10];
int32_t main() {
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        cin>>l[i];
    }
    sort(l, l+n, greater<int>());
    diff[0] = 1; diff[1] = -1;
    int j=0;
    int sum1=0, sum=0;
    int ans = -1;
    for(int i=0;i<N-1;i++) {
        sum1 += diff[i];
        sum += sum1;
        if(sum >= k) {
            ans = i;
            break;
        }
        if(sum + sum1 + diff[i+1] >= k) {
            ans = i+1;
            break;
        }
        int osum=sum1;
        while(sum1 && j < n) {
            diff[i]--; diff[i+1]++;
            int l1=l[j]/2;
            int l2 = l[j] - l1 - 1;
            diff[i+2]++; diff[i+2+l1]--;
            diff[i+2]++; diff[i+2+l2]--;
            j++;
            sum1--;
        }
        sum -= (osum - sum1);
    }
    cout<<ans<<endl;
    return 0;
}