#include <bits/stdc++.h>   using namespace std;   int a[1000006];   int n, k;   int max_a;   int has[20000007];   bool judge(int num) {     if (num == 1) return true;     int cnt = 0;     for (int i = 0; i < num * 2; i++) {       has[i] = i / num;     }     for (int i = num * 2; i <= max_a; i++) {       has[i] = has[i / 2] + has[i - i / 2];     }     for (int i = 0; i < n; i++) {       cnt += has[a[i]];       if (cnt >= k) {         return true;       }     }     return false;   }   int main() {     while (scanf( %d%d , &n, &k) != EOF) {       for (int i = 0; i < n; i++) {         scanf( %d , &a[i]);       }       long long sum = 0;       max_a = 0;       for (int i = 0; i < n; i++) {         sum += a[i];         if (a[i] > max_a) {           max_a = a[i];         }       }       if (sum < k) {         printf( -1 n );       } else {         int l = 1, r = max_a + 1;         while (l < r - 1) {           int m = (l + r) / 2;           if (judge(m)) {             l = m;           } else {             r = m;           }         }         while (judge(l)) {           l++;         }         cout << l - 1 << endl;       }     }   }   