#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e9;
const long double eps = 0.000001;
const long long mod = 1e9 + 7;
const long double PI = 3.14159265359;
template <class T>
struct MyVector : vector<T> {
  MyVector() : vector<T>() {}
  MyVector(long long n) : vector<T>(n) {}
  T &operator[](size_t i) { return vector<T>::at(i); }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(1e7 + 10, 0);
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a[x]++;
  }
  long long q = 0, idx = 1e7 + 9;
  while (q < k && idx >= 0) {
    q += a[idx];
    idx--;
  }
  idx++;
  for (long long i = 1e7 + 9; i > 64; i--) {
    if (a[i] <= 0) continue;
    long long r = i / 2 + (i % 2);
    long long l = i / 2;
    if (l < idx && r < idx) {
      break;
    }
    if (l >= idx) a[l] += a[i];
    if (r >= idx) a[r] += a[i];
    if (l >= idx && r >= idx) q += a[i];
    a[i] = 0;
    q -= a[idx];
    while (q >= k && idx < 1e7 + 9) {
      idx++;
      q -= a[idx];
    }
    q += a[idx];
  }
  for (long long i = 64; i > 1; i--) {
    if (a[i] <= 0) continue;
    long long r = i / 2 + (i % 2);
    long long l = i / 2;
    if (l < idx && r < idx) {
      break;
    }
    if (l >= idx) a[l] += a[i];
    if (r >= idx) a[r] += a[i];
    if (l >= idx && r >= idx) q += a[i];
    a[i] = 0;
    q -= a[idx];
    while (q >= k && idx < 1e7 + 9) {
      idx++;
      q -= a[idx];
    }
    q += a[idx];
  }
  if (idx == 0 || q < k) {
    cout << -1;
  } else {
    cout << idx;
  }
  return 0;
}
