#include using namespace std; int main() { ios_base::sync_with_stdio(0); int n, k; cin >> n >> k; vector l(n); for (int i = 0; i < n; i++) cin >> l[i]; int res = 0; vector t(n, true); for (int i = 30; i >= 0; i--) { int cnt = 0; for (int j = 0; j < n; j++) { if (t[j] && (l[j] & (1 << i))) cnt++; } if (cnt < k) continue; for (int j = 0; j < n; j++) { if ((l[j] & (1 << i)) == 0) t[j] = false; } res += (1 << i); } cout << res << endl; return 0; }