#include <bits/stdc++.h>
using namespace std;
long long n, k, a[1005];
vector<long long> v;
int main() {
  scanf("%lld%lld", &n, &k);
  a[0] = 0;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), a[i] += a[i - 1];
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) v.push_back(a[j] - a[i - 1]);
  long long ans = 0;
  for (int i = 40; i >= 0; i--) {
    long long p = 1ll << i, cot = 0;
    vector<long long> s;
    for (int j = 0; j < v.size(); j++)
      if (v[j] & p) s.push_back(v[j]), cot++;
    if (cot >= k) v = s, ans += p;
  }
  printf("%lld\n", ans);
}
