#include <bits/stdc++.h>
using namespace std;
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v) {
  os << "(";
  os << v.first << "," << v.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[";
  long long sz = v.size();
  for (long long i = 0; i < sz; ++i) {
    os << v[i];
    if (i != sz - 1) os << ",";
  }
  os << "]\n";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  T last = *v.rbegin();
  os << "[";
  for (auto it : v) {
    os << it;
    if (it != last) os << ",";
  }
  os << "]\n";
  return os;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &v) {
  for (auto it : v) {
    os << it.first << " : " << it.second << "\n";
  }
  return os;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % 1000000007;
    }
    b /= 2;
    a = (a * a) % 1000000007;
  }
  return res;
}
const long long N = 1e6 + 6;
long long n, k, mx, a[N], dp[10 * N];
bool check(long long x) {
  for (__typeof(mx) i = x; i <= mx; i++) {
    long long hlf = i / 2;
    if (hlf >= x)
      dp[i] = dp[hlf] + dp[i - hlf];
    else
      dp[i] = 1;
  }
  long long pieces = 0;
  for (__typeof(n) i = 1; i <= n; i++)
    if (a[i] >= x) {
      pieces += dp[a[i]];
      if (pieces >= k) break;
    }
  return pieces >= k;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (__typeof(n) i = 1; i <= n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  sort(a + 1, a + n + 1, greater<long long>());
  long long lo = 1, hi = mx, mid, ans = -1;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    if (check(mid)) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
