#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N);
  vector<ll> sum(N + 1);
  for (ll i = 0; i < N; ++i) cin >> a[i];
  for (ll i = 0; i < N; ++i) sum[i + 1] = sum[i] + a[i];
  vector<ll> b;
  for (ll i = 0; i < N; ++i)
    for (ll j = i; j < N; ++j) b.push_back(sum[j + 1] - sum[i]);
  ll fl = 0;
  set<ll> st;
  set<ll> st2;
  for (ll i = 30; i >= 0; --i) {
    if (fl == 0) {
      for (ll j = 0; j < b.size(); ++j) {
        if ((1LL << i) & b[j]) {
          st.insert(j);
        }
      }
      if (st.size() >= K) {
        fl = 1;
      } else {
        st.clear();
      }
    } else {
      for (ll j = 0; j < b.size(); ++j) {
        if ((1LL << i) & b[j] && st.count(j)) {
          st2.insert(j);
        }
      }
      if (st2.size() < K) {
        ll ans = b[*st.begin()];
        st.erase(st.begin());
        for (auto &x : st) ans = ans & b[x];
        cout << ans << endl;
        return 0;
      } else {
        st = st2;
        st2.clear();
      }
    }
  }
  if (st.size() >= K) {
    ll ans = b[*st.begin()];
    st.erase(st.begin());
    for (auto &x : st) ans = ans & b[x];
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
