#include <bits/stdc++.h>
using namespace std;
long long a[10000005], b[10000005], n, k;
long long check(long long x) {
  memset(a, 0, sizeof a);
  long long i, j, sum = 0;
  for (i = 1; i <= n; i++) a[b[i]]++;
  for (i = 10000005; i >= x; i--) {
    if ((i >> 1) >= x) {
      a[(i >> 1)] += a[i];
      a[i - (i >> 1)] += a[i];
    } else {
      sum += a[i];
    }
  }
  return sum >= k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j, mx = 0, sum = 0;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> b[i];
    sum += b[i];
  }
  if (sum < k) {
    cout << "-1";
    return 0;
  }
  long long hi = 10000000, lo = 0, mid;
  while (hi - lo > 1) {
    mid = (hi + lo) / 2;
    if (check(mid))
      lo = mid;
    else
      hi = mid;
  }
  if (check(hi))
    cout << hi;
  else if (check(mid))
    cout << mid;
  else
    cout << lo;
  return 0;
}
