#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int N = 1e7 + 10;
ll n, k;
ll mx;
ll a[maxn];
ll dp[N];
bool test(ll x) {
  for (int i = 0; i <= x; i++) {
    dp[i] = 0;
  }
  for (int i = x; i <= mx; i++) {
    dp[i] = max(1ll, dp[i / 2] + dp[(i + 1) / 2]);
  }
  ll need = k;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    need -= dp[x];
    if (need <= 0) return true;
  }
  return need <= 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    mx = max(mx, 1ll * a[i]);
  }
  if (k > sum) out(-1);
  ll lo = 1;
  ll hi = mx + 1;
  while (hi - lo > 1) {
    ll mid = (lo + hi) / 2;
    if (test(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << lo << endl;
  return 0;
}
