#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long

int main () {
  ll n, K;
  cin >> n >> K;
  ll a[n];
  ll sum[n + 1];
  sum[0] = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  vector<ll> ans;
  for (ll i = 0; i < n + 1; i++) {
    for (ll j = i + 1; j < n + 1; j++) {
      ans.push_back(sum[j] - sum[i]);  
    }  
  }
  ll sub = 1;
  ll itr = 0;
  ll dp[40];
  for (int i = 0; i < 40; i++) {
    dp[i] = 0;  
  }
  vector<unordered_map<ll, ll> > box;
  box.resize(40);
  for (ll i = 0; i < ans.size(); i++) {
    if (ans[i] == 0) {
      // 何もしない  
    }  
    itr = 0;
    while (ans[i] != 0) {
      if ((ans[i] & 1) == 1) {
        box[itr][i] = 1;
      }    
      ans[i] >>= 1;  
      itr++;
    }
  }
  /*
  while (itr < 41) {
    for (ll i = 0; i < ans.size(); i++) {
      if ((sub & ans[i]) != 0) {
        dp[itr]++;
        box[itr][i] = 1;  
      }    
    }  
    sub = sub * 2;
    itr++;  
  }
  */
  sub = 1;
  for (int i = 0; i < 40; i++) {
    /*
    cout << sub << " " << dp[i] << endl;
    for (auto x = box[i].begin(); x != box[i].end(); ++x) {
      cout << *x << " ";  
    }
    cout << endl;
    */
    sub = sub * 2;  
  }
  ll answer = 0;
  ll ssss = 0;
  bool ok = false;
  unordered_map<ll, ll> finish;
  for (ll i = 0; i < 40; i++) {
    sub = sub / 2;
    if (ok == false) {
      if (box[39 - i].size() >= K) {
        answer = answer + sub;
        ok = true;
        itr = 39 - i;
      }
    }
    else {
      ssss = 0;
      if (box[39 - i].size() >= K) {
        for (auto j = box[39 - i].begin(); j != box[39 - i].end(); ++j) {
          if (box[itr][j->first] == 1) {
              ssss++;      
          } 
          else {
            box[39 - i][j->first] = 0;    
          }
        }  
        if (ssss >= K) {
          answer = answer + sub;  
          itr = 39 - i;
        }
        else {
          // 何もしない.    
        }
      }     
    }
  }
  cout << answer << endl;
}
