#include <bits/stdc++.h>
using namespace std;
const int N = (1e6) + 1, M = (1e7) + 1;
int n, k, a[N], dp[M];
bool check(int x) {
  fill(dp + 1, dp + M, 0);
  for (int i = x; i <= (1e7); i++) dp[i] = max(dp[i >> 1] + dp[i + 1 >> 1], 1);
  long long sum = 0;
  for (int i = 0; i < n; i++) sum += dp[a[i]];
  return (sum >= k);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  int l = 0, r = 1e7;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  if (!l)
    printf("-1");
  else
    printf("%d", l);
}
