#include <bits/stdc++.h>
using namespace std;
int n, k;
const int maxn = 1e6 + 5;
const int MAXN = 1e7 + 5;
long long a[maxn];
long long b[MAXN];
long long betta;
long long me;
bool cnt(long long mid) {
  for (int i = 0; i < mid; i++) {
    b[i] = 0;
  }
  b[mid] = 1;
  for (int i = mid; i <= me; i++) {
    b[i] = max((long long)1, b[i / 2] + b[i / 2 + i % 2]);
  }
  long long cur = 0;
  for (int i = 0; i < n; i++) {
    cur += b[a[i]];
    if (cur >= k) {
      return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    betta += a[i];
    me = max(me, a[i]);
  }
  if (betta < k) {
    cout << -1;
    return 0;
  }
  long long mid = 1;
  long long r = me;
  long long l = 1;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (cnt(mid) == 1) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (cnt(r) == 1) {
    cout << r;
    return 0;
  }
  cout << l;
  return 0;
}
