#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;
const int MAX_A = 10000000;
long long cs[MAX_A + 1];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long long asum = 0;
  int maxa = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    asum += ai;
    maxa = max(maxa, ai);
    cs[ai]++;
  }
  if (asum < k) {
    puts("-1");
    return 0;
  }
  long long s = 0;
  for (int i = maxa, j = maxa; i > 0; i--) {
    s += cs[i];
    while (j > 0 && j / 2 >= i) {
      if (j & 1)
        cs[j / 2] += cs[j], cs[(j + 1) / 2] += cs[j];
      else
        cs[j / 2] += cs[j] * 2;
      s += cs[j];
      cs[j] = 0;
      j--;
    }
    if (s >= k) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
