#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000010;
long long a[maxn];
int main() {
  int n, k;
  long long sum = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    sum += x;
    ++a[x];
  }
  if (sum < k) {
    puts("-1");
    return 0;
  }
  sum = n;
  int p1 = 0, p2 = maxn - 1;
  while (sum < k) {
    sum += a[p2];
    a[p2 / 2] += a[p2];
    a[(p2 + 1) / 2] += a[p2];
    --p2;
  }
  while (sum - a[p1] >= k) {
    sum -= a[p1];
    ++p1;
  }
  while (p1 < p2 / 2) {
    sum += a[p2];
    a[p2 / 2] += a[p2];
    a[(p2 + 1) / 2] += a[p2];
    --p2;
    while (sum - a[p1] >= k) {
      sum -= a[p1];
      ++p1;
    }
  }
  printf("%d\n", p1);
  return 0;
}
