#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
long long maxa = -(1e7 + 100);
const long long inf = 2e18;
long long n, k;
vector<long long> a(maxn);
int main() {
  scanf("%I64d %I64d", &n, &k);
  long long sum = 0;
  long long r = -inf;
  for (int i = 0; i < n; ++i) {
    scanf("%I64d", &a[i]);
    r = max(r, a[i]);
    maxa = max(maxa, a[i]);
    sum += a[i];
  }
  if (sum < k) {
    printf("-1");
    return 0;
  }
  long long l = 0;
  r++;
  maxa++;
  while (l + 1 < r) {
    long long m = (l + r) / 2;
    long long cnt = 0;
    bool is = false;
    vector<long long> add(maxa, 0LL);
    if (m >= maxa) {
      is = false;
    } else {
      add[m] = 1;
      for (int i = m + 1; i < maxa; ++i)
        add[i] = max(1LL, add[i / 2] + add[(i + 1) / 2]);
      for (int i = 0; i < n; ++i) {
        long long cur = a[i];
        cnt += add[cur];
        if (cnt >= k) {
          is = true;
          break;
        }
      }
    }
    if (is)
      l = m;
    else
      r = m;
  }
  printf("%I64d", l);
  return 0;
}
