#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
using ll = long long;
using namespace std;
const double PI = acos(-1);
const int M = 1000000007;
// const int M = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k, int m = M) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2, m);
  ax = mod(ax * ax, m);
  if (k % 2) ax = mod(ax * n, m);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

int N;
vector<int> st;
vector<int> lz;

// #define PRINT_TEST_CASE
// #define MULTIPLE_TEST_CASE

void push(int cur, int l, int r) {
  if (!lz[cur]) return;
  st[cur] += (r - l + 1) * lz[cur];
  if (l != r) {
    lz[2 * cur] += lz[cur];
    lz[2 * cur + 1] += lz[cur];
  }
  lz[cur] = 0;
}

int qry(int a, int b, int cur = 1, int l = 0, int r = N - 1) {
  push(cur, l, r);
  if (r < a || b < l) return 0;
  if (a <= l && r <= b) return st[cur];
  int m = (l + r) >> 1;
  return qry(a, b, 2 * cur, l, m) + qry(a, b, 2 * cur + 1, m + 1, r);
}

void upd(int a, int b, int val, int cur = 1, int l = 0, int r = N - 1) {
  push(cur, l, r);
  if (r < a || b < l) return;
  if (a <= l && r <= b) {
    lz[cur] += val;
    push(cur, l, r);
    return;
  }
  int m = (l + r) >> 1;
  upd(a, b, val, 2 * cur, l, m);
  upd(a, b, val, 2 * cur + 1, m + 1, r);
  st[cur] = st[2 * cur] + st[2 * cur + 1];
}

void solution(int testcase) {
#ifdef PRINT_TEST_CASE
  cout << "Case #" << testcase << ": ";
#endif
  // Code starts here
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  sort(all(a), greater<int>());
  N = a[0] + 2000;
  st.clear();
  lz.clear();
  st.resize(4 * N, 0);
  lz.resize(4 * N, 0);

  int ans = INF;

  auto find_depth = [&](int val = 1) {
    int l = 0, r = N - 1;
    int ans = -1;
    while (l <= r) {
      int m = (l + r) >> 1;
      if (qry(0, m) >= val) {
        ans = m;
        r = m - 1;
      } else
        l = m + 1;
    }
    return ans;
  };

  upd(0, 0, 1);

  for (int x : a) {
    int d = find_depth();
    upd(d, d, -1);
    upd(d + 2, d + 2 + (x - 1) / 2 - 1, 1);
    upd(d + 2, d + 2 + (x - 1) - (x - 1) / 2 - 1, 1);

    int nw = find_depth(k);
    ans = min(ans, nw != -1 ? nw : (ll)INF);
  }
  cout << (ans == INF ? -1 : ans) << endl;
}

int32_t main() {
  DESYNC;
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  for (int _testcase = 1; _testcase <= t; _testcase++) solution(_testcase);
}
