#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e6 + 1;
const int maxn = 1e6;
int n, k, x, mx;
int a[N], b[N];
char c;
string s, s2;
long long sum;
long long cnt[maxn * 10 + 2];
vector<int> G[N];
map<string, int> mp1;
map<int, string> mp2;
priority_queue<int> q[N];
void init() {
  memset(a, 0, sizeof a);
  memset(b, 0, sizeof b);
  memset(cnt, 0, sizeof cnt);
  sum = 0;
  mx = -23;
}
int main() {
  scanf("%d%d", &n, &k);
  init();
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    cnt[a[i]]++;
    sum += (long long)a[i];
    mx = ((mx > a[i]) ? mx : a[i]);
  }
  if (sum < k) {
    puts("-1");
    return 0;
  }
  sum = 0;
  int ans;
  for (int i = mx; i; i--) {
    sum += cnt[i];
    if (i * 2 <= mx) sum -= cnt[i << 1];
    if (i * 2 - 1 <= mx && i != 1) sum -= cnt[(i * 2) - 1];
    if (sum >= k) {
      ans = i;
      printf("%d\n", ans);
      break;
    }
    cnt[i >> 1] += cnt[i];
    cnt[i + 1 >> 1] += cnt[i];
  }
  return 0;
}
