#include <bits/stdc++.h>
#define all(n) (n).begin(), (n).end()
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define sqr(n) (n) * (n)
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define precision(a) setiosflags(ios::fixed) << setprecision(a)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef double db;

template <typename T> inline char read(T& x) {
    x = 0; T fg = 1; char ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') fg = -1; ch = getchar(); }
    while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ '0'), ch = getchar();
    x = fg * x; return ch;
}
template <typename T, typename... Args> inline void read(T& x, Args &... args) { read(x), read(args...); }
template <typename T> inline void write(T x) {
    int len = 0; char c[21]; if (x < 0) putchar('-'), x = -x;
    do { ++len; c[len] = x % 10 + '0'; } while (x /= 10);
    for (int i = len; i >= 1; i--) putchar(c[i]);
}
template <typename T, typename... Args> inline void write(T& x, Args &... args) { write(x), write(args...); }

template<class T1, class T2> bool umin(T1& a, T2 b) { return a > b ? (a = b, true) : false; }
template<class T1, class T2> bool umax(T1& a, T2 b) { return a < b ? (a = b, true) : false; }
template<class T> void clear(T& a) { T().swap(a); }

const int N = 1151300;

int n, m, _, k;
ll c[2][N + 1], ans = 2e18;

void add(int x, ll k) {
    for (int i = x; i <= N; i += -i & i) c[0][i] += k, c[1][i] += x * k;
}

void add(int l, int r, ll k) { add(l, k); add(r + 1, -k); }

ll ask(int x) {
    ll p = 0, q = 0, f = x + 1;
    for (; x; x -= -x & x) p += c[0][x], q += c[1][x];
    return p * f - q;
}

ll ask(int l, int r) { return ask(r) - ask(l - 1); }

ll kth(int k) {
    if (ask(N) < k) return 2e18;
    int l = 1, r = N;
    while (l < r) {
        ll mid = l + r >> 1, c;
        if ((c = ask(l, mid)) < k) k -= c, l = mid + 1;
        else r = mid; 
    }
    return l;
}

int main() {
    IOS; cin >> n >> k; VI a(n);
    for (auto &i : a) cin >> i, --i; sort(all(a));
    add(2, 2 + a.back() >> 1, 1); add(2, 2 + a.back() + 1 >> 1, 1); umin(ans, kth(k));
    per (i, n - 2, 0) {
        int cur = kth(1); add(cur, cur, -1);
        add(cur + 2, 1 + cur + (a[i] >> 1), 1); add(cur + 2, 1 + cur + (a[i] + 1 >> 1), 1);
        umin(ans, kth(k));
    }
    cout << (ans == 2e18 ? -1 : ans);
    return 0;
}