#include <bits/stdc++.h>
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbd(a) cout << #a << ": " << a << endl
#define dbd2(a,b) cout << #a << ": " << a << ", " << #b << ": " << b << endl 
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto _i:a) cout << _i << " "; cout << endl
#define adbp(a) for(auto _i:a) cout << _i.first << " " << _i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define N 300010
#define M 100010
using namespace std;

long long tree[4*N], lazy[4*N];

void update(int node, int l, int r, int i, int j, long long val)
{
    if(lazy[node])
    {
        tree[node] += lazy[node] * (r - l + 1);

        if(l != r)
        {
            int lc = 2*node, rc = 2*node + 1;
            lazy[lc] += lazy[node];
            lazy[rc] += lazy[node];
        }

        lazy[node] = 0;
    }

    if(l > j || r < i) return;

    if(l >= i && r <= j)
    {
        tree[node] += val * (r - l + 1);

        if(l != r)
        {
            int lc = 2*node, rc = 2*node + 1;
            lazy[lc] += val;
            lazy[rc] += val;
        }
        return;
    } 

    int lc = 2*node, rc = 2*node + 1, m = (l + r)/2;

    update(lc, l, m, i, j, val);
    update(rc, m+1, r, i, j, val);

    tree[node] = tree[lc] + tree[rc];
}

long long query(int node, int l, int r, int i, int j)
{
    if(lazy[node])
    {
        tree[node] += lazy[node] * (r - l + 1);

        if(l != r)
        {
            int lc = 2*node, rc = 2*node + 1;
            lazy[lc] += lazy[node];
            lazy[rc] += lazy[node];
        }

        lazy[node] = 0;
    }

    if(l > j || r < i) return 0;

    if(l >= i && r <= j) return tree[node];

    int lc = 2*node, rc = 2*node + 1, m = (l + r)/2;

    return query(lc, l, m, i, j) + query(rc, m+1, r, i, j);
}

int binsearch(int k)
{
    int low = 0, high = N, ans = INT_MAX;

    while(low <= high)
    {
        int mid = (low + high)/2;

        if(query(1, 0, N-1, 0, mid) >= k) ans = mid, high = mid - 1;
        else low = mid + 1;
    }

    return ans;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif

    fastIO;
    long long n, k;
    cin >> n >> k;

    long long l[n];
    for(int i=0; i<n; i++) cin >> l[i], l[i]--;

    sort(l, l+n, greater<long long>());

    multiset<pair<long long, long long>> st;
    st.insert({0, 0});
    update(1, 0, N-1, 0, 0, 1);

    int ans = INT_MAX;

    for(int i=0; i<n; i++)
    {
        pair<long long, long long> p = *(st.begin());
        st.erase(st.begin());

        int u = p.first + 2, d1 = p.first + 1 + l[i]/2, d2 = d1 + l[i]%2;

        st.insert({u, d1});
        update(1, 0, N-1, u, d1, 1);
        st.insert({u, d2});
        update(1, 0, N-1, u, d2, 1);

        if(p.first + 1 <= p.second) st.insert({p.first + 1, p.second});
        update(1, 0, N-1, p.first, p.first, -1);

        ans = min(ans, binsearch(k));
    }

    if(ans == INT_MAX) ans = -1;

    cout << ans << endl;
}