#include <bits/stdc++.h>
using namespace std;
int n, k, a[1000010];
long long asum;
int p2[25];
long long test(int v) {
  long long tot = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] < v) continue;
    int f = max(0, (int)log2(a[i] / v));
    while (p2[f] * v <= a[i]) f++;
    int add = p2[f] / 2 + max(0, a[i] - (p2[f] * v - p2[f] / 2));
    tot += add;
  }
  return tot;
}
int main() {
  p2[0] = 1;
  for (int i = 1; i < 25; i++) p2[i] = p2[i - 1] * 2;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    asum += a[i];
  }
  if (asum < k) {
    puts("-1");
    return 0;
  }
  int lo = 1, hi = 1e7 + 1;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (test(mid) >= k)
      lo = mid + 1;
    else
      hi = mid;
  }
  printf("%d\n", lo - 1);
  return 0;
}
