#include <bits/stdc++.h>
const int maxn = 1e6;
using namespace std;
int num[maxn + 10];
int n, k;
bool cmp(int x, int y) { return x > y; }
int q[10 * maxn + 100];
int MAX;
bool check(int m) {
  for (int i = 0; i < m; i++) q[i] = 0;
  q[m] = 1;
  for (int i = m; i <= MAX; i++)
    q[i] = max(1, q[i >> 1] + q[(i >> 1) + (i & 1)]);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += q[num[i]];
    if (sum >= k) break;
  }
  if (sum >= k)
    return 1;
  else
    return 0;
}
int binarysearch(int L, int R) {
  int ret = R;
  while (L <= R) {
    int mid = (R - L) / 2 + L;
    if (check(mid)) {
      L = mid + 1;
      ret = mid;
    } else
      R = mid - 1;
  }
  return ret;
}
int main() {
  MAX = 0;
  scanf("%d%d", &n, &k);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &num[i]);
    ans += num[i];
    MAX = max(MAX, num[i]);
  }
  sort(num, num + n, cmp);
  if (ans < k)
    printf("-1\n");
  else {
    ans = binarysearch(1, MAX);
    printf("%d\n", ans);
  }
}
