#include <bits/stdc++.h>
using namespace std;
int mod = (int)1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int oo = (int)1e9;
const int MAX = 10000009;
int n;
long long m;
int a[MAX];
long long dp[MAX];
long long fun(int x, long long mid) {
  long long& r = dp[x];
  if (r != -1) return dp[x];
  if (x < mid) return r = 0;
  if (x / 2 < mid) return r = 1;
  return r = fun(x / 2, mid) + fun(x - x / 2, mid);
}
int calc(int x, long long mid) {
  int r = x / mid;
  if (r == 0) return 0;
  r = (int)log2(r);
  return (1 << r);
}
bool check(long long mid) {
  memset(dp, -1, sizeof dp);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += fun(a[i], mid);
    if (sum >= m) return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  long long l = 1, r = sum / m, ans = -1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << ans << endl;
  return 0;
}
