#include<bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10;
int n, k;

struct chain {
    int l, r;

    inline bool operator<(chain a) const {
        return l > a.l;
    }
};

priority_queue<chain> q;
int a[N];

inline bool check(int x) {
    while (!q.empty())q.pop();
    int num = 1;
    q.push({0, 0});
    int p = n;
    while (num < k) {
        if (q.empty())return false;
        chain t = q.top();
        if (t.l + 2 > x)return false;
        q.pop();
        if (!p)return false;
        num--;
        if (t.l < t.r)q.push({t.l + 1, t.r});
        int l = a[p--];
        if (t.l + 4 <= x) {
            q.push({t.l + 2, t.l + (l + 1) / 2});
            q.push({t.l + 2, t.l + l / 2 + 1});
        }
        num += min(x, t.l + (l + 1) / 2) - (t.l + 2) + 1;
        num += min(x, t.l + l / 2 + 1) - (t.l + 2) + 1;
    }
    return true;
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i)scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    int l = 2, r = k + 1;
    while (l < r) {
        int mid = (l + r) >> 1;
        check(mid) ? r = mid : l = mid + 1;
    }
    printf("%d\n", l == k + 1 ? -1 : l);
    return 0;
}