#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using ld = long double;
mt19937 rnd(time(nullptr));
const int SZ = 1e7;
int n = 0, k = 0;
vector<int> data;
lli buffer[SZ + 1];
lli GetValue(int a, int m) {
  if (buffer[a] != -1) return buffer[a];
  int b = a / 2;
  if (b < m)
    buffer[a] = 1;
  else if (b * 2 == a)
    buffer[a] = 2LL * GetValue(b, m);
  else
    buffer[a] = GetValue(b + 1, m) + GetValue(b, m);
  return buffer[a];
}
bool Check(int m) {
  if (m == 0) return true;
  if (m == 1) {
    lli sum = 0;
    for (auto it : data) sum += it;
    return (sum >= k);
  }
  if (m >= SZ + 1) return false;
  memset(buffer, 0, sizeof(buffer));
  buffer[m] = 1;
  for (int i = m + 1; i <= SZ; i++) {
    buffer[i] = max(1LL, buffer[i / 2] + buffer[i / 2 + i % 2]);
  }
  lli counter = 0;
  for (auto it : data) {
    counter += buffer[it];
  }
  return (counter >= k);
}
inline void Solve() {
  cin >> n >> k;
  data.resize(n);
  for (auto &it : data) cin >> it;
  int l = 0, r = 1e7 + 100;
  while (r - l > 1) {
    int m = l + (r - l) / 2;
    if (Check(m))
      l = m;
    else
      r = m;
  }
  if (l == 0)
    cout << -1;
  else
    cout << l;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(20);
  Solve();
  return 0;
}
