#pragma GCC optimize("O3")
#pragma G++ optimize("O3")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//#define DEBUG
const int maxn = 2e6+10;
const int mod = 1e9+7;
const int N = 2e6;

ll n,a[maxn];
ll k;

ll sum[maxn<<2],add[maxn<<2]; //根节点下标为1
inline void push_up(int rt)  //rt代表当前节点
{
    sum[rt] = sum[rt<<1]+sum[rt<<1 | 1];   //父亲节点是子节点的和
}

inline void push_down(int rt,int m)  //m是更新的区间长度
{
    if(add[rt]){
        //将懒惰标记更新到下一层
        add[rt<<1] += add[rt];
        add[rt<<1 | 1] += add[rt];
        sum[rt<<1] += (m-(m>>1))*add[rt];
        sum[rt<<1 | 1] += (m>>1)*add[rt];
        //取消本层的懒惰标记
        add[rt] = 0;
    }
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
void build(int l,int r,int rt) //建树时根节点从1开始
{
    add[rt] = 0;
    if(l == r){
        if(l == 1) sum[rt] = 1;
        else sum[rt] = 0;
        return;
    }
    int mid = (l+r)>>1;
    build(lson);
    build(rson);
    push_up(rt); //回溯的时候更新区间和
}

inline void update(int a,int b,ll c,int l,int r,int rt)
{
    if(a <= l && b >= r){
        sum[rt] += (r-l+1)*c;
        add[rt] += c;
        return;
    }
    push_down(rt,r-l+1);
    int mid = (l+r)>>1;
    if(a <= mid) update(a,b,c,lson);
    if(b > mid) update(a,b,c,rson);
    push_up(rt);
}

inline int query(ll k,int l,int r,int rt)
{
    if(l == r) return l;
    push_down(rt,r-l+1);
    int mid = (l+r)>>1;
    if(sum[rt<<1] >= k) return query(k,lson);
    else return query(k-sum[rt<<1],rson);
}

inline ll qu(int a,int b,int l,int r,int rt)
{
    if(a <= l && b >= r) return sum[rt];
    push_down(rt,r-l+1);   //你需要用到下一层的sum，必须更新这一层的lazy
    int mid = (l+r)>>1;
    ll ans = 0;
    if(a <= mid) ans += qu(a,b,lson);
    if(b > mid) ans += qu(a,b,rson);
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifdef DEBUG
        freopen("E:\acm\acm训练\example\ac.in","r",stdin);
        freopen("E:\acm\acm训练\example\ac.out","w",stdout);
    #endif

    cin>>n>>k;
    for(int i=0;i < n;++i) cin>>a[i];

    if(k == 1) {cout<<0; return 0;}

    sort(a,a+n,greater<int>());
    ll ans = 1,idx = 1;
    int res = 1e9;
    update(1,1,1,1,N,1);
    int flag = 1;
    for(int i=0;i < n;++i)
    {
        idx = query(1,1,N,1);
        update(idx,idx,-1,1,N,1);
        int tmp = a[i]-1;
        update(idx+2,idx+1+tmp/2,2,1,N,1);
        if(tmp%2) update(idx+2+tmp/2,idx+2+tmp/2,1,1,N,1);

        ans = ans + a[i] - 2;

        if(ans >= k) {flag = 0;res = min(res,query(k,1,N,1));}
    }
    if(flag) cout<<-1;
    else cout<<res-1;

    return 0;
}
