#include <bits/stdc++.h>
using namespace std;
long long f[10000001];
int main() {
  long long n, k, a, b;
  cin >> n >> k;
  long long tot = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    f[a]++;
    tot += a;
  }
  if (tot < k) {
    cout << -1;
    return 0;
  }
  long long cnt = 0;
  int j = 1;
  for (int i = 1e7; i >= 1; i--) {
    cnt += f[i];
    if (cnt >= k) {
      j = i;
      break;
    }
  }
  for (int i = 1e7; i >= 2; i--) {
    a = i / 2;
    b = i - i / 2;
    if (a >= j and b >= j) {
      cnt += f[i];
      f[a] += f[i];
      f[b] += f[i];
      f[i] = 0;
      while (cnt - f[j] >= k) {
        cnt -= f[j];
        j++;
      }
    } else
      break;
  }
  cout << j;
}
