#include <bits/stdc++.h>
using namespace std;
const int maxn = 1024000;
int N, K, Max;
int v[maxn], dp[maxn * 10];
int dfs(int x, int cur) {
  if (dp[x] != -1) return dp[x];
  int &ans = dp[x];
  if (x < cur) return ans = 0;
  if (x == cur) return ans = 1;
  int a = x / 2, b = x - x / 2;
  return ans = max(1, dfs(a, cur) + dfs(b, cur));
}
bool judge(int cur) {
  memset(dp, -1, sizeof(dp));
  long long sum = 0;
  for (int i = 0; i < N; ++i) {
    if (v[i] < cur) break;
    sum += dfs(v[i], cur);
    if (sum >= K) return true;
  }
  return sum >= K;
}
int main() {
  scanf("%d%d", &N, &K);
  long long sum = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", v + i);
    sum += v[i];
    Max = max(Max, v[i]);
  }
  sort(v, v + N, greater<int>());
  if (sum < K) {
    puts("-1");
    return 0;
  }
  int L = 1, R = Max + 1, ok = 1;
  while (L < R) {
    int mid = L + (R - L) / 2;
    if (judge(mid)) {
      ok = mid;
      L = mid + 1;
    } else {
      R = mid;
    }
  }
  printf("%d\n", ok);
  return 0;
}
