#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e2 + 10;
const int maxm = 1e7 + 10;
int n, m, luna[maxm], saika[maxm];
long long tot;
int maxa = 0;
namespace FastIO {
bool IOError = 0;
inline char NextChar() {
  static char buf[10000000], *p1 = buf + 10000000, *pend = buf + 10000000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 10000000, stdin);
    if (pend == p1) {
      IOError = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool Blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
template <class T>
inline bool Read(T &x) {
  char ch;
  while (Blank(ch = NextChar()))
    ;
  if (IOError) return false;
  for (x = 0; '0' <= ch && ch <= '9'; ch = NextChar())
    x = (x << 3) + (x << 1) + ch - '0';
  return true;
}
};  // namespace FastIO
using namespace FastIO;
bool check(int x) {
  long long cnt = 0;
  for (int i = 1; i <= maxa; i++) saika[i] = luna[i];
  for (int i = maxa; i > 0; i--) {
    if (i >= 2 * x) {
      saika[i / 2] += saika[i];
      saika[i / 2 + i % 2] += saika[i];
      continue;
    }
    if (i >= x) cnt += saika[i];
  }
  return cnt >= m;
}
int main(int argc, char const *argv[]) {
  cin >> n >> m;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    Read(x);
    ans += x;
    luna[x]++;
    maxa = max(maxa, x);
  }
  if (ans < m) {
    cout << -1;
    return 0;
  }
  int le = 0, ri = maxa;
  while (le < ri) {
    int mid = (le + ri + 1) >> 1;
    if (check(mid))
      le = mid;
    else
      ri = mid - 1;
  }
  if (le == 0) le++;
  cout << le << endl;
  return 0;
}
