#include using namespace std; int main(){ int n, k, res = 0; cin >> n >> k; int mus[n]; bool ingr[n]; for (int i = 0; i < n; i++){ ingr[i] = true; cin >> mus[i]; } for (int d = 29; d >= 0; d--){ int count = 0; for (int i = 0; i < n; i++){ if (!ingr[i]) continue; if ((1 << d) & mus[i]) count++; } if (count >= k){ res += (1 << d); for (int i = 0; i < n; i++){ if (!ingr[i]) continue; if (((1 << d) & mus[i]) == 0) ingr[i] = false; } } } cout << res << endl; }