#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 5;
long long a[maxn] = {0};
int main() {
  int n;
  cin >> n;
  long long k;
  cin >> k;
  int x, l = maxn, r = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    ++a[x];
    if (l > x) l = x;
    if (r < x) r = x;
  }
  long long cnt = n;
  while (cnt - a[l] >= k) {
    cnt -= a[l];
    l++;
  }
  while (cnt < k) {
    if (r == 1) break;
    a[r / 2] += a[r];
    a[r - r / 2] += a[r];
    cnt += a[r];
    if (l > r / 2) l = r / 2;
    r--;
  }
  if (cnt < k) return puts("-1"), 0;
  while (r / 2 > l) {
    a[r / 2] += a[r];
    a[r - r / 2] += a[r];
    cnt += a[r];
    while (cnt - a[l] >= k) {
      cnt -= a[l];
      l++;
    }
    r--;
  }
  cout << l << endl;
  return 0;
}
