#include <bits/stdc++.h>
using namespace std;
int n, k;
long long d[10000005];
long long ara[10000005 / 10];
void precalc() {
  for (int i = 0; i <= 24; i++) {
    for (int j = (1 << i); j <= min((1 << (i + 1)) - 1, 10000000); j++)
      d[j] = i;
  }
}
bool okay(long long mid) {
  if (mid == 1) return 1;
  long long temp = 0;
  for (int i = 0; i < n; i++) {
    if (ara[i] < mid) continue;
    long long vag = ara[i] / mid;
    if ((1 << d[vag]) == vag)
      temp += vag;
    else {
      temp += max((1LL << d[vag]), ara[i] - (mid - 1) * (1LL << (d[vag] + 1)));
    }
  }
  return (temp >= k);
}
int main() {
  precalc();
  scanf("%d %d", &n, &k);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &ara[i]);
    sum += ara[i];
  }
  if (sum < k) {
    printf("-1\n");
    return 0;
  }
  int lo = 1, hi = 10000000;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (okay(mid))
      lo = mid;
    else
      hi = mid - 1;
  }
  printf("%d\n", lo);
}
