#include <bits/stdc++.h>
using namespace std;
template <class htpe, class cmp>
using heap = priority_queue<htpe, vector<htpe>, cmp>;
template <class htpe>
using min_heap = heap<htpe, greater<htpe> >;
template <class htpe>
using max_heap = heap<htpe, less<htpe> >;
const int INF = 1791791791;
const long long INFLL = 1791791791791791791ll;
template <size_t buf_size>
class FastInput {
  char buf[buf_size];
  size_t clen = 0;
  size_t cpos = 0;
  FILE *infl;
  bool cl = false;

 public:
  inline bool isEof() {
    if (cpos == clen) {
      cpos = 0;
      clen = fread(buf, 1ul, buf_size, infl);
      return clen == 0;
    } else
      return false;
  }
  inline int nextChar() { return isEof() ? -1 : buf[cpos++]; }
  inline bool seekEof() {
    int res = nextChar();
    while (res == ' ' || res == '\n') res = nextChar();
    if (res == -1) return true;
    assert(cpos != 0);
    cpos--;
    return false;
  }
  inline char readChar() {
    int res = nextChar();
    while (res == ' ' || res == '\n') res = nextChar();
    assert(res != -1);
    return (char)res;
  }
  inline void copyWord(char *wbuf) {
    int w = readChar();
    while (w != ' ' && w != '\n' && w != -1) {
      *(wbuf++) = (char)w;
      w = nextChar();
    }
  }
  inline string readString() {
    int w = readChar();
    std::string res;
    while (w != ' ' && w != '\n' && w != -1) {
      res.push_back((char)w);
      w = nextChar();
    }
    return res;
  }
  template <class rint_t = int>
  rint_t readInt() {
    int sgn = readChar();
    rint_t res = 0, b = 1;
    if (sgn == '-')
      b = -1;
    else if (sgn != '+')
      res = sgn - '0';
    int w = nextChar();
    while (w != ' ' && w != '\n' && w != -1) {
      res *= 10;
      res += w - '0';
      w = nextChar();
    }
    return b * res;
  }
  FastInput(const string &filename = "stdin") {
    cl = filename != "stdin";
    if (filename == "stdin")
      infl = stdin;
    else
      infl = fopen(filename.c_str(), "r");
  }
  ~FastInput() {
    if (cl) fclose(infl);
  }
};
template <size_t buf_size>
class FastOutput {
  char buf[buf_size];
  int cpos = 0;
  FILE *outfl;
  bool lf, cl;

 public:
  inline void flush() {
    fwrite(buf, cpos, 1, outfl);
    cpos = 0;
  }
  inline void putChar(char c) {
    if (cpos == buf_size) flush();
    buf[cpos++] = c;
  }
  inline void putBuf(const char *to_w) {
    while (*to_w != 0) putChar(*(to_w++));
  }
  inline void writeString(const string &s, const char *after = " ") {
    putBuf(s.c_str());
    putBuf(after);
  }
  template <class rint_t>
  inline void writeInt(rint_t x, const char *after = " ") {
    char to_w[100];
    int cur = 0;
    if (x == 0)
      putBuf("0");
    else {
      if (x < 0) {
        putChar('-');
        x = -x;
      }
      while (x > 0) {
        to_w[cur++] = (x % 10) + '0';
        x /= 10;
      }
      reverse(to_w, to_w + cur);
      to_w[cur] = 0;
      putBuf(to_w);
    }
    putBuf(after);
  }
  inline void writeEndl() { putChar('\n'); }
  FastOutput(const string &filename = "stdout", bool lflush = true) {
    lf = lflush;
    cl = filename != "stdout";
    if (filename == "stdout")
      outfl = stdout;
    else
      outfl = fopen(filename.c_str(), "w");
    memset(buf, 0, sizeof(buf));
  }
  ~FastOutput() {
    flush();
    if (cl) fclose(outfl);
  }
};
FastInput<4096> fin;
FastOutput<4096> fout;
const int maxb = 1e7 + 179;
long long cnum[2 * maxb];
int main() {
  int n = fin.readInt();
  int k = fin.readInt();
  for (int i = 0; i < ((int)(n)); ++i) cnum[fin.readInt()]++;
  long long csum = 0;
  for (int ans = maxb - 1; ans >= 1; ans--) {
    csum += cnum[ans];
    for (int i = 2 * ans + 1; i >= 2 * ans; i--) {
      cnum[i / 2] += cnum[i];
      cnum[(i + 1) / 2] += cnum[i];
      csum -= cnum[i];
      if (i / 2 >= ans) csum += cnum[i];
      if ((i + 1) / 2 >= ans) csum += cnum[i];
    }
    if (csum >= k) {
      fout.writeInt(ans, "\n");
      return 0;
    }
  }
  fout.writeInt(-1, "\n");
  return 0;
}
