#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
const int maxN = 1000005;
const int maxA = 10000005;
int n, k;
int a[maxN];
long long cnt[maxA], sub[maxA];
int main(int argc, char** argv) {
  scanf("%d %d", &n, &k);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
    cnt[a[i]]++;
  }
  long long tot = 0;
  for (int i = mx; i; i--) {
    tot += cnt[i] - sub[i];
    cnt[i / 2] += cnt[i];
    cnt[(i + 1) / 2] += cnt[i];
    sub[(i + 1) / 2] += cnt[i];
    if (tot >= k) {
      printf("%d\n", i);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
