#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<long long> p;
  for (int i = 0; i < 25; i++) {
    p.push_back(1 << i);
  }
  long long ans = -1, lo = 1, hi = 1e7, mid;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    vector<long long> vii;
    vii.push_back(mid);
    vii.push_back(mid);
    vii.push_back(mid * 2);
    vii.push_back(mid * 2);
    int i = 2;
    while (1) {
      int t1 = mid * (1 << i);
      int t2 = (1 << (i - 1)) - 1;
      vii.push_back(t1 - t2);
      vii.push_back(t1);
      if (t1 > 10000000) break;
      i++;
    }
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i] < mid) continue;
      auto it = upper_bound(vii.begin(), vii.end(), arr[i]) - vii.begin();
      it--;
      if (it % 2)
        cnt += p[it / 2];
      else {
        cnt += p[it / 2] / 2 + 1 + arr[i] - vii[it];
      }
    }
    if (cnt >= k) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  cout << ans << "\n";
}
