#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int M = 1e7 + 5;
int a[N];
int n, k;
int aMax;
long long dp[M];
bool check(int mid) {
  memset(dp, 0, sizeof(dp));
  for (int i = mid; i <= aMax; ++i) {
    long long tmp = dp[i >> 1] + dp[(i >> 1) + (i & 1)];
    dp[i] = (tmp > 1) ? tmp : 1;
  }
  long long cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += dp[a[i]];
  }
  return cnt >= k;
}
void solve() {
  cin >> n >> k;
  long long total = 0;
  aMax = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    total += a[i];
    aMax = (aMax > a[i]) ? aMax : a[i];
  }
  if (total < k) {
    cout << "-1" << endl;
    return;
  }
  int l = 1, r = M;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << l - 1 << endl;
}
int main() {
  solve();
  return 0;
}
