#include <bits/stdc++.h>
using namespace std;
int const INF = 1e9 + 7;
long long const LLINF = 1e18 + 7;
long double const eps = 1e-8;
long double const PI = acos(-1);
long long const p_hash = 257;
long long const mod = 1e9 + 9;
bool operator==(pair<int, int> const& a, pair<int, int> const& b) {
  return (a.first == b.first && a.second == b.second);
}
pair<int, int> operator+(pair<int, int> const& a, pair<int, int> const& b) {
  return {a.first + b.first, a.second + b.second};
}
pair<int, int> operator-(pair<int, int> const& a, pair<int, int> const& b) {
  return {a.first - b.first, a.second - b.second};
}
long long dp[10000010];
long long a[2000020];
long long n, k;
inline bool ok(int const& nd) {
  for (int i = nd; i <= 1e7; i++) {
    if (i / 2 >= nd)
      dp[i] = dp[i / 2] + dp[i - i / 2];
    else
      dp[i] = 1;
  }
  long long res = 0;
  for (int i = 0; i < n; i++)
    if (a[i] >= nd) res += dp[a[i]];
  return (res >= k);
}
int main() {
  scanf("%lld%lld", &n, &k);
  long long mass = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    mass += a[i];
  }
  if (mass < k) {
    printf("-1");
    return 0;
  }
  cerr << ok(7);
  int l = 0, r = 1e7 + 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (ok(m))
      l = m;
    else
      r = m;
  }
  if (ok(r))
    printf("%d", r);
  else
    printf("%d", l);
  return 0;
}
