#include <bits/stdc++.h>

using namespace std;
typedef long long ll;


ll MSB(ll N){
  ll k = (ll)log2l(N);
  return k;
}

int main(){
  ll n, k; cin >> n >> k;
  ll arr[n];
  for(int i=0;i<n;++i) cin >> arr[i];
  vector<ll> subs;
  for(int i=0;i<n;++i){
    ll sum = 0;
    for(int j=i;j<n;++j){
      sum += arr[j];
      subs.push_back(sum);
    }
  }
  ll p = 40;
  ll ans = 0;
  while(p>=0){
    ll cont = 0;
    ans += (1ll<<p);
    for(int i=0;i<subs.size();++i){
      if((subs[i] & ans)==ans) cont++;
    }
    if(cont < k) ans -= (1ll<<p);
    p--;
  }
  cout << ans << endl;
}