#include <bits/stdc++.h>
using namespace std;
long long int n, e, a[1000100], l, m, r = 1e13;
;
bool ok(long long int x) {
  long long int sum = 0, y, z, k;
  for (int i = 0; i < n; ++i) {
    y = a[i];
    z = y >= x;
    k = (y + 1) / 2;
    while (k > x) z *= 2, y = k, k = (y + 1) / 2;
    if (k == x) z *= 2, z = max(z + a[i] - k * z, z / 2);
    sum += z;
  }
  return sum >= e;
}
int main() {
  scanf("%lld%lld", &n, &e);
  for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);
  while (l < r) {
    m = (l + r + 1) / 2;
    if (ok(m))
      l = m;
    else
      r = m - 1;
  }
  printf("%lld", (l ? l : -1));
}
