#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long count1[10000000 + 1];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  long long n;
  long long k;
  cin >> n >> k;
  int x = 0, y;
  int a[n];
  for (int i = 0; i < 10000000 + 1; i++) {
    count1[i] = 0;
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > x) {
      x = a[i];
    }
    count1[a[i]]++;
    sum += a[i];
  }
  if (sum < k) {
    cout << -1 << flush;
    return 0;
  }
  while (n < k) {
    count1[x / 2] += count1[x];
    count1[(x + 1) / 2] += count1[x];
    n += count1[x];
    count1[x] = 0;
    while (count1[x] == 0) {
      x--;
    }
  }
  y = x;
  sum = 0;
  while (1) {
    if (sum + count1[y] < k) {
      sum += count1[y];
      y--;
    } else {
      count1[y] = k - sum;
      for (int i = 0; i < y; i++) {
        count1[i] = 0;
      }
      break;
    }
  }
  while ((x / 2) > y) {
    count1[x / 2] += count1[x];
    count1[(x + 1) / 2] += count1[x];
    long long delta = count1[x];
    count1[x] = 0;
    while (count1[x] == 0) {
      x--;
    }
    while (count1[y] < delta) {
      delta -= count1[y];
      count1[y] = 0;
      while (count1[y] == 0) {
        y++;
      }
    }
    count1[y] -= delta;
    while (count1[y] == 0) {
      y++;
    }
  }
  cout << y << flush;
  return 0;
}
