#include <bits/stdc++.h>
using namespace std;
int k, n, a[1000010];
int f[10000010], ha[10000010], tim;
long long sum;
int cal(int x, int t) {
  if (ha[x] == tim) return f[x];
  ha[x] = tim;
  if (x < t) return f[x] = 0;
  if (x / 2 < t) return f[x] = 1;
  if (x & 1) return f[x] = cal(x / 2, t) + cal(x / 2 + 1, t);
  return f[x] = 2 * cal(x / 2, t);
}
bool check(int x) {
  tim++;
  long long all = 0;
  for (int i = 1; i <= n; i++) {
    all += cal(a[i], x);
    if (all >= k) return 1;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i];
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  if (sum < k) return puts("-1"), 0;
  int l = 1, r = 1e7, ans = 1;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid))
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d\n", ans);
}
