#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
int n;
long long int k;
int arr[10000005];
long long int memo[10000005];
long long int dfs(int mn, int num) {
  if (num < mn) return 0;
  if (memo[num] != -1) return memo[num];
  long long int res = 1;
  if (num != 1) {
    if (num & 1) {
      res = max(res, dfs(mn, num >> 1) + dfs(mn, (num + 1) >> 1));
    } else {
      res = max(res, dfs(mn, num >> 1) << 1);
    }
  }
  return memo[num] = res;
}
bool check(int mn) {
  long long int cur = 0;
  memset(memo, -1, (arr[n - 1] + 1) * sizeof(long long int));
  for (int i = n - 1; i >= 0; --i) {
    cur += dfs(mn, arr[i]);
    if (cur >= k) break;
  }
  if (cur >= k) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  while (cin >> n >> k) {
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    int lo = 1;
    int hi = 10000001;
    int mi;
    while (lo <= hi) {
      mi = (lo + hi) >> 1;
      if (check(mi)) {
        lo = mi + 1;
      } else {
        hi = mi - 1;
      }
    }
    if (!hi)
      cout << "-1\n";
    else
      cout << hi << "\n";
  }
  return 0;
}
