#include <bits/stdc++.h>
int ex[] = {1, -1, 0, 0};
int wye[] = {0, 0, 1, -1};
using namespace std;
int n, k, a[1000005], mp[10000005];
inline int process(int cur, int num) {
  if (mp[cur] > -1) return mp[cur];
  if (cur < num) return 0;
  int num1 = cur >> 1, num2 = (cur + 1) >> 1;
  if ((num1 < num && num2 < num) || cur == num) return 1;
  return mp[cur] = process(num1, num) + process(num2, num);
}
bool check(int num) {
  long long int lol, pop = 0;
  memset(mp, -1, sizeof(mp));
  for (long long int i = 1; i <= n; i++) {
    if (a[i] < num) break;
    if (num == 1)
      lol = 1ll * a[i];
    else
      lol = 1ll * process(a[i], num);
    pop += lol;
  }
  if (pop >= 1ll * k)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1, greater<int>());
  int lo = 1, hi = 1e7 + 5, mid, an = -1;
  while (lo <= hi) {
    mid = (lo + hi) >> 1;
    if (check(mid)) {
      an = mid;
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  printf("%d\n", an);
  return 0;
}
