#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int a[maxn], n, k, d[10 * maxn];
int dp(int x, int u) {
  if (x < u) return 0;
  if (d[x] != 0) return d[x];
  if (x / 2 < u) return d[x] = 1;
  if (x & 1) {
    d[x] = dp(x / 2, u);
    return d[x] += dp(x / 2 + 1, u);
  }
  return d[x] = 2 * dp(x / 2, u);
}
bool check(int u) {
  long long s = 0;
  for (int i = n - 1; i >= 0; i--) {
    int tem = dp(a[i], u);
    if (tem)
      s += tem;
    else
      break;
  }
  if (s >= k) return true;
  return false;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int ans = -1;
  int l = 0, r = 1e7 + 1, mid;
  while (l + 1 < r) {
    mid = l + (r - l) / 2;
    memset(d, 0, sizeof(d));
    if (check(mid)) {
      ans = max(ans, mid);
      l = mid;
    } else
      r = mid;
  }
  printf("%d\n", ans);
  return 0;
}
