#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int n, k;
int arr[MAXN];
vector<int> pai[MAXN];
int deets[10000015];
int get(int a) { return deets[a]; }
int main() {
  deets[0] = -1;
  for (int i = 1; i <= 10000000; i++) {
    if (!(i & (i - 1)))
      deets[i] = deets[i - 1] + 1;
    else
      deets[i] = deets[i - 1];
  }
  scanf("%d %d\n", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  for (int i = 1; i <= n; i++) {
    int kt = arr[i];
    int num0 = 1, num1 = 0;
    while (1) {
      pai[i].push_back(num1);
      if (kt == 1) break;
      if (kt & 1) {
        int cp_num0 = num0;
        int cp_num1 = num1;
        kt /= 2;
        num0 = cp_num0;
        num1 = cp_num0 + 2 * cp_num1;
      } else {
        int cp_num0 = num0;
        int cp_num1 = num1;
        kt /= 2;
        num0 = 2 * cp_num0 + cp_num1;
        num1 = cp_num1;
      }
    }
    reverse(pai[i].begin(), pai[i].end());
  }
  int lo = 0, hi = 1e7;
  while (hi > lo) {
    int mid = (hi + lo + 1) / 2;
    long long tot = 0;
    for (int i = 1; i <= n; i++) {
      if (mid > arr[i]) continue;
      if (mid == 1) {
        tot += arr[i];
        continue;
      }
      int maxi = 1 << (get(arr[i] / mid));
      int lak = get(arr[i] / (mid - 1));
      int ke = pai[i][pai[i].size() - 1 - lak];
      maxi = max(maxi, ke);
      tot += maxi;
    }
    if (tot >= k) {
      lo = mid;
    } else
      hi = mid - 1;
  }
  if (lo == 0)
    cout << -1 << '\n';
  else
    cout << lo << '\n';
  return 0;
}
