#include <bits/stdc++.h>
using namespace std;
const long long N = 1e7 + 5;
long long sum[N], suffix[2 * N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    sum[x] += 1;
  }
  for (long long i = N; i >= 2; i--) {
    sum[i / 2] += sum[i];
    sum[(i + 1) / 2] += sum[i];
  }
  for (int i = N; i >= 2; i--) {
    suffix[i] = suffix[i + 1] + sum[i];
    if (suffix[i] - suffix[i * 2 - 1] >= k) {
      printf("%d\n", i);
      return 0;
    }
  }
  if (sum[1] >= k)
    puts("1");
  else
    puts("-1");
}
