#include <stdio.h>
#include <memory.h>
#include <algorithm>
using namespace std;

const int N = 200005;
int a[4 * N] = { 0 }, z[4 * N] = { 0 }, v[N] = { 0 };
void insert(int id, int p, int q, int pp, int qq) {
    if (pp > q) return;
    if (qq > q) qq = q;
    if (p == pp && q == qq) {
        a[id] ++;
        z[id] += (q - p + 1);
        return;
    }
    int mid = (p + q) / 2, left = id + id + 1, right = left + 1;
    if (a[id]) {
        a[left] += a[id];
        z[left] += a[id] * (mid - p + 1);
        a[right] += a[id];
        z[right] += a[id] * (q - mid);
        a[id] = 0;
    }
    if (qq <= mid) insert(left, p, mid, pp, qq);
    else if (pp > mid) insert(right, mid + 1, q, pp, qq);
    else {
        insert(left, p, mid, pp, mid);
        insert(right, mid + 1, q, mid + 1, qq);
    }
    z[id] = z[left] + z[right];
}

int get(int id, int p, int q) {
    z[id] --;
    if (p == q) {
        return p;
    }
    int mid = (p + q) / 2, left = id + id + 1, right = left + 1;
    if (a[id]) {
        a[left] += a[id];
        z[left] += a[id] * (mid - p + 1);
        a[right] += a[id];
        z[right] += a[id] * (q - mid);
        a[id] = 0;
    }
    if (z[left]) return get(left, p, mid);
    return get(right, mid + 1, q);
}

int main() {
    int n = 0, k = 0, now = 0, i = 0, p = 0, q = 0, mid = 0;
    long long now2 = 0;
    while (scanf("%d%d", &n, &k) == 2) {
        now2 = 1;
        for (i = 0; i < n; i ++) {
            scanf("%d", v + i);
            now2 += v[i] - 2;
        }
        if (now2 < k) {
            printf("%d\n", -1);
            continue;
        }
        sort(v, v + n);
        p = 3;
        q = N;
        while (p <= q) {
            mid = (p + q) / 2;
            memset(z, 0, sizeof(z));
            memset(a, 0, sizeof(a));
            insert(0, 1, mid, 1, 1);
            for (i = n - 1; i >= 0; i --) {
                now = get(0, 1, mid);
                insert(0, 1, mid, now + 2, now + 1 + (v[i] - 1) / 2);
                insert(0, 1, mid, now + 2, now + 1 + v[i] / 2);
                //printf("$$$$$$$$$$$$$$ %d %d %d\n", now + 2, now + 1 + (v[i] - 1) / 2, now + 1 + v[i] / 2);
                //printf("## %d %d %d %d\n", mid, now, v[i], z[0]);
                if (z[0] >= k || z[0] <= 0) break;
            }
            if (z[0] >= k) q = mid - 1;
            else p = mid + 1;
        }
        printf("%d\n", p - 1);
    }
    return 0;
}
