#include <bits/stdc++.h>
const int maxn = 1e6 + 10;
const int inf = 1e7 + 10;
using namespace std;
int n;
long long k, a[maxn];
long long cnt[inf], vis[inf];
inline long long read() {
  long long res = 0;
  bool flag = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') flag = 0;
    c = getchar();
  }
  while (c <= '9' && c >= '0')
    res = (res << 3) + (res << 1) + c - '0', c = getchar();
  return flag ? res : -res;
}
bool cmp(long long a, long long b) { return a > b; }
inline int dfs(int res, int mid) {
  if (vis[res] != -1) return vis[res];
  if (res == 1) {
    vis[res] = 1;
    return 1;
  }
  int ji = (res >> 1) + 1, ou = res >> 1;
  if (res >= (mid << 1)) {
    if (res & 1) {
      return vis[res] = ((vis[ji] = dfs(ji, mid)) + (vis[ou] = dfs(ou, mid)));
    } else {
      return vis[res] = ((vis[ou] = dfs(ou, mid)) << 1);
    }
  } else if (res >= mid) {
    vis[res] = 1;
    return 1;
  } else
    return vis[res] = 0;
}
inline bool pd(long long mid) {
  memset(vis, -1, sizeof(vis));
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] >= mid) {
      sum += dfs(a[i], int(mid));
    } else
      return 0;
    if (sum >= k) return 1;
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  k = read();
  long long sum = 0;
  for (int i = 1; i <= n; i++) a[i] = read(), sum += a[i];
  if (sum < k) {
    printf("-1");
    return 0;
  }
  sort(a + 1, a + n + 1, cmp);
  long long l = 1, r = inf;
  long long mid, ans = -1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (pd(mid))
      l = mid + 1, ans = mid;
    else
      r = mid - 1;
  }
  cout << ans;
  return 0;
}
