#include <bits/stdc++.h>
using namespace std;
long long int arr[10000050];
int prev(int cur) {
  while (cur > 0 && arr[cur] == 0) {
    cur--;
  }
  return cur;
}
int next(int cur, int skip) {
  int start;
  for (int i = cur; i < 10000050; i++) {
    if (arr[i] > 0) {
      if (arr[i] <= skip) {
        skip -= arr[i];
        start = i;
      } else {
        arr[i] -= skip;
        start = i;
        break;
      }
    }
  }
  return start;
}
int main() {
  int n;
  long long k;
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    arr[x]++;
  }
  int end;
  long long int ctr = 0;
  long long int possible = 0;
  for (int i = 0; i < 10000050; i++) {
    if (arr[i] > 0) {
      end = i;
      ctr += arr[i];
      possible += arr[i] * 1LL * i;
    }
  }
  int skip = ctr - k;
  if (possible < k) {
    cout << "-1\n";
  } else {
    while (skip < 0) {
      int a = end / 2;
      int b = a;
      if (end % 2 != 0) a++;
      int cnt = arr[end];
      arr[a] += cnt;
      arr[b] += cnt;
      arr[end] = 0;
      end = prev(end);
      skip += cnt;
    }
    int start = next(0, skip);
    while (1) {
      if (end / 2 <= start) {
        break;
      }
      int a = end / 2;
      int b = a;
      if (end % 2 != 0) a++;
      int cnt = arr[end];
      arr[a] += cnt;
      arr[b] += cnt;
      arr[end] = 0;
      end = prev(end);
      start = next(start, cnt);
    }
    cout << start << '\n';
  }
}
