#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll inf = 2e9;
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
template <class t> using oset = tree<t, null_type, less <t>, rb_tree_tag, tree_order_statistics_node_update>;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    vector <ll> v(n);
    for (auto &x : v) cin >> x;
    ll curans = 0;
    for (ll i = 31 ; i >= 0 ; i--){
        ll curbro = curans | (1LL << i);
        ll cnt = 0, cur = 0;
        for (auto &x : v){
            cur |= x;
            if ((cur & curbro) == curbro){
                cnt++;
                cur = 0;
            }
        }
        if (cnt >= k){
            curans = curbro;
        }
    }
    cout << curans << "\n";
}
