#include using namespace std; typedef long long ll; vector X, buf; int n, k, x, ans; int main(){ ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i ++){ cin >> x; X.push_back(x); } for (int i = 30; i >= 0; i --){ int res = 0; for (auto e : X) res += (((1 << i) & e) > 0); if (res >= k){ ans += (1 << i); for (auto e : X) if (e & (1 << i)) buf.push_back(e); X = buf; buf.clear(); } } cout << ans << endl; return 0; }