#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e6 + 7;
const int Inf = 1 << 30;
const long long INF = 1ll << 60;
priority_queue<int> qua;
long long a[maxx];
vector<long long> vec;
int n, k;
long long ans;
void Init() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    long long sum = 0;
    for (int j = i; j <= n; j++) {
      sum += a[j];
      vec.push_back(sum);
    }
  }
}
void solve() {
  for (int bit = 59; bit >= 0; bit--) {
    int t = 0;
    int sz = vec.size();
    for (int i = 0; i < sz; i++) {
      long long dd = 1ll << bit;
      if (vec[i] & dd) t++;
    }
    if (t < k) continue;
    vector<long long> tmp;
    tmp.clear();
    for (int i = 0; i < sz; i++) {
      long long dd = 1ll << bit;
      if (vec[i] & dd) tmp.push_back(vec[i]);
    }
    vec = tmp;
    ans += 1ll << bit;
  }
}
int main() {
  Init();
  solve();
  cout << ans << endl;
}
