#include <bits/stdc++.h>
using namespace std;
int n, k;
long long sum = 0;
int a[10000005] = {};
int mx = 0;
int main() {
  std::cin.sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    mx = max(mx, t);
    a[t]++;
    sum += t;
  }
  if (sum < k) {
    cout << -1;
    return 0;
  }
  int have = n;
  for (int i = mx; i >= 2; i--) {
    if (have >= k) break;
    if (a[i] == 0) continue;
    int t1, t2;
    if (i % 2 == 0)
      t1 = t2 = i >> 1;
    else
      t2 = i >> 1, t1 = t2 + 1;
    int cur = a[i];
    have += cur;
    a[t1] += cur;
    a[t2] += cur;
    a[i] = 0;
  }
  set<int> q;
  int tmp = 0;
  for (int i = mx; i >= 1; i--) {
    if (a[i] == 0) continue;
    tmp += a[i];
    q.insert(i);
    if (tmp >= k) break;
  }
  int bestAns = *q.begin();
  for (int i = mx; i >= 2; i--) {
    if (a[i] == 0) continue;
    int t1, t2;
    if (i % 2 == 0)
      t1 = t2 = i >> 1;
    else
      t2 = i >> 1, t1 = t2 + 1;
    if (t1 > bestAns) {
      int cur = a[i];
      a[t1] += cur;
      a[t2] += cur;
      q.insert(t1);
      q.insert(t2);
      q.erase(i);
      a[i] = 0;
      while (cur > 0) {
        if (cur >= a[bestAns]) {
          cur -= a[bestAns];
          a[bestAns] = 0;
          q.erase(bestAns);
          bestAns = *q.begin();
        } else {
          a[bestAns] -= cur;
          cur = 0;
        }
      }
    }
  }
  cout << bestAns;
  return 0;
}
