#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2, M = 1e7 + 2;
int n, k, ar[N], mp[M];
inline bool check(int md) {
  memset(mp, 0, sizeof(mp));
  for (int i = md; i <= 1e7; i++) {
    if (i < md + md)
      mp[i] = 1;
    else
      mp[i] = mp[(i >> 1)] + mp[((i + 1) >> 1)];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += mp[ar[i]];
    if (ans >= k) return true;
  }
  return false;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%I64d", &ar[i]);
  int l = 0, r = 1e9 + 7;
  while (r - l > 1) {
    int md = (l + r) >> 1;
    if (check(md))
      l = md;
    else
      r = md;
  }
  if (l == 0)
    cout << -1;
  else
    cout << l;
}
