#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline void writeln(int x) {
  char buffor[21];
  register int i = 0;
  int neg = 0;
  if (x < 0) {
    neg = 1;
    x = -x;
  }
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
const int A = (int)1e7 + 1;
long long dem[2 * A];
int n;
long long k;
void input() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    dem[a]++;
  }
}
void solve() {
  long long all = 0;
  for (int i = (int)1e7; i >= 1; i--) {
    all += dem[i];
    all -= dem[i * 2] + dem[i * 2 - 1];
    if (i == 1) all += dem[1];
    if (all >= k) {
      cout << i;
      return;
    }
    if (i % 2 == 0)
      dem[i / 2] += dem[i] * 2;
    else {
      dem[i / 2] += dem[i];
      dem[i / 2 + 1] += dem[i];
    }
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  solve();
  return 0;
}
