#include <bits/stdc++.h>
using namespace std;
const int radix_len = 1e7 + 5;
long long cnt[radix_len];
int main() {
  int n, k, a;
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  long long tot = 0;
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
    cin >> a;
    cnt[a]++;
    tot += a;
  }
  if (tot < k) {
    cout << -1 << endl;
    return 0;
  }
  auto bound = 1;
  auto sum = 0LL;
  for (int i = radix_len - 1; i > 0; i--) {
    sum += cnt[i];
    if (sum >= k) {
      bound = i;
      break;
    }
  }
  for (int i = radix_len - 1; i > 1; i--) {
    if (i / 2 < bound) break;
    cnt[i / 2] += cnt[i];
    cnt[i - i / 2] += cnt[i];
    sum += cnt[i];
    cnt[i] = 0;
    while (sum - cnt[bound] >= k) {
      sum -= cnt[bound];
      bound++;
    }
  }
  cout << bound << endl;
}
