#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
const int maxa = 1e7 + 100;
const long long inf = 2e18;
long long n, k;
vector<long long> a(maxn);
bool check(long long m) {
  long long cnt = 0;
  vector<long long> add(maxa, 0LL);
  if (m >= maxa) {
    return false;
  }
  add[m] = 1;
  for (int i = m + 1; i < maxa - 50; ++i)
    add[i] = max(1LL, add[i / 2] + add[(i + 1) / 2]);
  for (int i = 0; i < n; ++i) {
    long long cur = a[i];
    cnt += add[cur];
    if (cnt >= k) return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  long long sum = 0;
  long long r = -inf;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    r = max(r, a[i]);
    sum += a[i];
  }
  if (sum < k) {
    cout << "-1";
    return 0;
  }
  long long l = 0;
  r++;
  while (l + 1 < r) {
    long long m = (l + r) / 2;
    if (check(m))
      l = m;
    else
      r = m;
  }
  cout << l;
  return 0;
}
