// Author : heyuhhh
// Created Time : 2020/12/29 18:59:47
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e5 + 5, MAX_DEEP = 2e6 + 5;

int n, k;
int a[N];

ll sumv[MAX_DEEP + 1 << 2], lz[MAX_DEEP + 1 << 2];
void tag(int o, int l, int r, ll v) {
    sumv[o] += 1ll * (r - l + 1) * v;
    if (lz[o] == INF) lz[o] = v;
    else lz[o] += v;
}

void push_up(int o) {
    sumv[o] = sumv[o << 1] + sumv[o << 1|1];
}

void push_down(int o, int l, int r) {
    if(lz[o] != INF) {
        int mid = (l + r) >> 1;
        tag(o << 1, l, mid, lz[o]);
        tag(o << 1|1, mid + 1, r, lz[o]);
        lz[o] = INF;   
    }
}

void build(int o, int l, int r) {
    lz[o] = INF;
    if(l == r) {
        if (l == 1) sumv[o] = 1;
        else sumv[o] = 0;
        return;
    }
    int mid = (l + r) >> 1;
    build(o << 1, l, mid), build(o << 1|1, mid + 1, r);
    push_up(o);
}

void update(int o, int l, int r, int L, int R, ll v) {
    if(L <= l && r <= R) {
        tag(o, l, r, v);
        return;
    }   
    push_down(o, l, r);
    int mid = (l + r) >> 1;
    if(L <= mid) update(o << 1, l, mid, L, R, v);
    if(R > mid) update(o << 1|1, mid + 1, r, L, R, v);
    push_up(o);
}

ll query(int o, int l, int r, int L, int R) {
    if(L <= l && r <= R) {
        return sumv[o];
    }
    push_down(o, l, r);
    int mid = (l + r) >> 1;
    ll res = 0;
    if(L <= mid) res += query(o << 1, l, mid, L, R);
    if(R > mid) res += query(o << 1|1, mid + 1, r, L, R);
    return res;
}

int find_dep(int o, int l, int r) {
    if (l == r) {
        return l;
    }
    push_down(o, l, r);
    int mid = (l + r) >> 1;
    if (sumv[o << 1] > 0) return find_dep(o << 1, l, mid);
    return find_dep(o << 1|1, mid + 1, r);
}

int queryAns(int o, int l, int r, int K) {
    if (l == r) {
        return l;
    }
    push_down(o, l, r);
    int mid = (l + r) >> 1;
    if (sumv[o << 1] >= K) return queryAns(o << 1, l, mid, K);
    return queryAns(o << 1|1, mid + 1, r, K - sumv[o << 1]);
}

void run() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    ll tot = 1;
    bool flag = false;
    for (int i = 1; i <= n; i++) {
        tot += a[i] - 2;
        if (tot >= k) {
            flag = true;
            break;
        }
    }
    if (!flag) {
        cout << -1 << '\n';
        return;
    }
    int ans = INF;
    build(1, 1, MAX_DEEP);
    for (int i = 1; i <= n; i++) {
        int last = find_dep(1, 1, MAX_DEEP);
        update(1, 1, MAX_DEEP, last, last, -1);
        if (a[i] & 1) {
            int l = last + 2, r = last + 1 + a[i] / 2;
            update(1, 1, MAX_DEEP, l, r, 2);
        } else {
            int l = last + 2, r = last + a[i] / 2;
            update(1, 1, MAX_DEEP, l, r, 2);
            ++r;
            update(1, 1, MAX_DEEP, r, r, 1);
        }
        if (sumv[1] >= k) {
            int res = queryAns(1, 1, MAX_DEEP, k) - 1;
            ans = min(ans, res);
        }
    }
    cout << ans << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}