#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long int n, k;
long long int freq[10000001] = {0};
long long int neg[10000001] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int i;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    long long int kk;
    cin >> kk;
    freq[kk]++;
  }
  long long int cnt = 0;
  long long int ans = -1;
  for (i = 10000000; i >= 1; i--) {
    cnt += freq[i];
    cnt -= neg[i];
    if (cnt >= k) {
      ans = i;
      break;
    }
    neg[(i + 1) / 2] += freq[i];
    freq[(i + 1) / 2] += freq[i];
    freq[(i) / 2] += freq[i];
  }
  cout << ans;
}
