#include using namespace std; typedef long long LL; typedef long double LD; typedef pair < int, int > PII; typedef pair < LL, LL > PLL; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() const int N = 2e5 + 7; int n, k; vector < int > vec; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++) { int x; cin >> x; vec.push_back(x); } int ans = 0; for(int b = 29; b >= 0; b--) { vector < int > zer, one; for(auto x: vec) { if(x & (1 << b)) one.push_back(x); else zer.push_back(x); } if(sz(one) >= k) { vec = one; ans += (1 << b); } } cout << ans << "\n"; return 0; }