#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
inline void read(long long &x) {
  x = 0;
  register char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + (c - '0');
}
inline void write(long long x) {
  register char buffor[35];
  register long long i = 0;
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
inline long long in() {
  long long x;
  read(x);
  return x;
}
void solve();
long long dbg = 1;
using namespace std;
int main() {
  long long t = 1;
  for (long long i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
long long a[1000005];
void solve() {
  long long ans, n, k, l, r, sum = 0, maxr = 0;
  read(n), read(k);
  for (long long i = 0; i < n; i++) {
    read(a[i]);
    sum += a[i];
    maxr = max(maxr, a[i]);
  }
  if (sum < k) {
    cout << -1 << endl;
    return;
  }
  l = 1;
  r = maxr;
  while (l < r) {
    ans = 0;
    long long mi = (l + r) / 2 + 1;
    for (long long i = 0; i < n; i++) {
      long long q = a[i], br = 1;
      if (q < mi) continue;
      while (q >= mi) {
        q /= 2;
        br *= 2;
      }
      long long v = br / 2;
      if (q == mi - 1) v = max(v, a[i] % br);
      ans += v;
      if (ans >= k) break;
    }
    if (ans < k)
      r = mi - 1;
    else
      l = mi;
  }
  cout << l << endl;
}
