#include <bits/stdc++.h>
using namespace std;
int N, inp, i, sl[10000001], ct[10000001];
long long pu, M;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M;
  for (i = 0; i < N; i++) {
    cin >> inp;
    sl[inp]++;
  }
  for (i = 10000000; i > 0; i--) {
    pu += sl[i];
    sl[i / 2] += sl[i] + ct[i];
    ct[i - i / 2] += sl[i] + ct[i];
    if (pu >= M) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
