#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// source: Me, based off github/the-tourist/algo
class segtree {
public:
    struct node {
        ll val;
        ll lazyVal;
        bool identity;
        node() {
            val = lazyVal = 0;
            identity = false;
        }

        void apply(int l, int r, ll v) {
            //make sure to update lazyVal here
            val += (r - l + 1) * v;
            lazyVal += v;
        }
    };
    
    node unite(const node &a, const node &b) const {
        // combines two nodes
        if(a.identity) return b;
        if(b.identity) return a;
        node res;
        res.val = a.val + b.val;
        return res;
    }

    inline void push(int x, int l, int r) {
        // return; if no lazy prop
        // make sure to reset lazyValue here, lazy is added in apply function
        int mid = (l + r) >> 1;
        if (l != r) {
            tree[2 * x].apply(l, mid, tree[x].lazyVal);
            tree[2 * x + 1].apply(mid + 1, r, tree[x].lazyVal);
        }
        tree[x].lazyVal = 0;
    }

    inline void pull(int x) { tree[x] = unite(tree[2 * x], tree[2 * x + 1]); }

    int n;
    vector<node> tree;
    segtree(int _n) : n(_n) {
        assert(n > 0);
        tree.resize(4 * n);
        build(1, 0, n - 1);
    }
    template <typename M>
    segtree(const vector<M> &v) {
        n = v.size();
        assert(n > 0);
        tree.resize(4 * n);
        build(1, 0, n - 1, v);
    }
    node get(int ll, int rr) {
        assert(0 <= ll && ll <= rr && rr <= n - 1);
        return get(1, 0, n - 1, ll, rr);
    }
    int bS(int v){
        return bS(1, 0, n - 1, v);
    }
    template <typename... M>
    void modify(int ll, int rr, const M &... v) {
        assert(0 <= ll && ll <= rr && rr <= n - 1);
        modify(1, 0, n - 1, ll, rr, v...);
    }

private:
    void build(int x, int l, int r) {
        if (l == r) {
            return;
        }
        int mid = (l + r) >> 1;
        build(2 * x, l, mid);
        build(2 * x + 1, mid + 1, r);
        pull(x);
    }
    template <typename M>
    void build(int x, int l, int r, const vector<M> &v) {
        if (l == r) {
            tree[x].apply(l, r, v[l]);
            return;
        }
        int mid = (l + r) >> 1;
        build(2 * x, l, mid, v);
        build(2 * x + 1, mid + 1, r, v);
        pull(x);
    }
    int bS(int x, int l, int r, int v) {
        if(tree[x].val < v) return -1;
        if(l==r) return l;
        int mid = (l + r) >> 1;
        push(x, l, r); 
        int res;
        if(v <= tree[2*x].val) res = bS(2*x, l, mid, v);
        else res = bS(2*x+1, mid+1, r, v-tree[2*x].val);
        pull(x);
        return res;
    }
    node get(int x, int l, int r, int ll, int rr) {
        node res{};
        res.identity = true;
        if (ll > r || l > rr) return res;
        if (ll <= l && r <= rr) return tree[x];
        int mid = (l + r) >> 1;
        push(x, l, r);
        res = unite(get(2 * x, l, mid, ll, rr),
                    get(2 * x + 1, mid + 1, r, ll, rr));
        pull(x);
        return res;
    }
    template <typename... M>
    void modify(int x, int l, int r, int ll, int rr, const M &... v) {
        if (ll > r || l > rr) return;
        if (ll <= l && r <= rr) {
            tree[x].apply(l, r, v...);
            return;
        }
        int mid = (l + r) >> 1;
        push(x, l, r);
        modify(2 * x, l, mid, ll, rr, v...);
        modify(2 * x + 1, mid + 1, r, ll, rr, v...);
        pull(x);
    }
};
const int MAXN = 2e5;
void run_case(){
    int n, k;
    cin>>n>>k;
    vector<int> l(n); 
    ll sum = 1;
    for(int& i:l) {
        cin>>i;
        sum += i;
    }
    sum -= 2 * n;
    if(sum<k){
        cout<<"-1\n";
        return;
    }
    
    sort(l.begin(), l.end(), greater<int>());
    segtree st(2*MAXN);
    st.modify(0, 0, 1);
    int ans = -1;
    int ind = 0;
    for(int i = 0; i< n; i++){
        while(st.get(ind, ind).val==0) ind++;
        st.modify(ind, ind, -1);
        int len = l[i]/2;
        st.modify(ind+2, ind+2+len-1, 1);
        st.modify(ind+2, ind+2+(l[i]-1-len)-1, 1);
        // cout<<ind<<" "<<len<<" "<<ind+2+(l[i]-1-len)<<endl;
        // cout<<st.get(2,2).val<<endl;
        // cout<<st.get(3,3).val<<endl;
        int cur = st.bS(k);
        if(cur!=-1) {
            // cout<<i<<" "<<cur<<endl;
            if(ans==-1 || cur < ans)
                ans = cur;
        }
    }
    cout<<ans<<'\n';

}
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    if (fopen("input.in", "r")) 
        freopen("input.in", "r", stdin), freopen("output.out", "w", stdout);
    int t;
    t=1;
    while(t--){
        run_case();
    }
}
