#include <bits/stdc++.h>
using namespace std;
string s;
int a[2000000], k, n;
int dp[10000001];
int f(int x, int y) {
  if (x <= 1e6) return dp[x];
  if (y > x) return 0;
  if (2 * y > x) return 1;
  if (x % 2 == 1)
    return f(x / 2, y) + f(x / 2 + 1, y);
  else
    return 2 * f(x / 2, y);
}
bool ok(int x) {
  for (int i = 0; i < x; i++) dp[i] = 0;
  for (int i = x; i < 2 * x && i <= 1e6; i++) dp[i] = 1;
  for (int i = 2 * x; i <= 1e6; i++)
    if (i % 2 == 0)
      dp[i] = dp[i / 2] + dp[i / 2];
    else
      dp[i] = dp[i / 2] + dp[i / 2 + 1];
  int s = 0;
  for (int i = 0; i < n; i++) {
    s += f(a[i], x);
    if (s >= k) return 1;
  }
  return 0;
}
int main() {
  cin >> n >> k;
  long long second = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    second += a[i];
  }
  if (k > second) {
    cout << -1;
    return 0;
  }
  long long l = 0, r = 1e7 + 1;
  while (r - l > 3) {
    int mid = (r + l) / 2;
    if (ok(mid))
      l = mid;
    else
      r = mid - 1;
  }
  for (int i = r; i >= l; i--)
    if (ok(i)) {
      cout << i;
      return 0;
    }
}
