#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int ans = -1;
long long s[10000005], cnt;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = (1); i <= (n); i++) {
    scanf("%d", &x);
    s[x]++;
  }
  cnt = n;
  int r = 10000000;
  for (int i = (1); i <= (10000000); i++) {
    while (cnt < k && r > i) {
      int a = r / 2, b = (r + 1) / 2;
      if (s[r] + cnt > k && a >= i) {
        s[a] += k - cnt;
        s[b] += k - cnt;
        s[r] -= k - cnt;
        cnt += k - cnt;
        break;
      } else {
        s[a] += s[r];
        if (a >= i) cnt += s[r];
        s[b] += s[r];
        if (b >= i) cnt += s[r];
        cnt -= s[r];
        s[r] = 0;
      }
      r--;
    }
    if (cnt >= k) ans = max(ans, i);
    cnt -= s[i];
  }
  printf("%d\n", ans);
  return 0;
}
