#include <bits/stdc++.h>
using namespace std;


const int N = 2e5 + 7;


int l[N];


int chk(int len, int n, int k) {
    multiset <pair <int, int> > st;
    st.insert(make_pair(0, 0));

    int white_count = 1;

    for(int i = 1; i <= n; i++) {
        auto [s, e] = *st.begin(); 
        st.erase(st.begin());
        if(s == len) return 0;
        int a = (l[i] - 1) / 2, b = (l[i] - 1 - a);
        int ax = min(len, s + a + 1), bx = min(len, s + b + 1);
        white_count += (ax - s - 1) + (bx - s - 1) - 1;
        if(white_count >= k) return 1;
        st.insert(make_pair(s + 2, ax));
        st.insert(make_pair(s + 2, bx));
        if(s + 1 <= e) {
            st.insert(make_pair(s + 1, e));
        }
    }
    return 0;
}

int32_t main() {
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> l[i];

    sort(l + 1, l + n + 1, greater <int> ());
    
    int lx = 1, rx = 1000001;

    while(lx < rx) {
        int mid = (lx + rx) / 2;
        if(chk(mid, n, k)) rx = mid;
        else               lx = mid + 1;
    }

    cout << (lx <= 1000000 ? lx : -1) << endl;

    
}