#include <bits/stdc++.h>
using namespace std;
int usable[1000009];
int main() {
  int n, k;
  vector<long long> a, bsum, num;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  bsum.push_back(0);
  for (int i = 0; i < n; i++) {
    bsum.push_back(bsum[i] + a[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      num.push_back(bsum[i] - bsum[j]);
    }
  }
  long long ans = 0;
  for (int i = 63; i >= 0; i--) {
    int cnt = 0;
    for (int j = 0; j < num.size(); j++) {
      if (usable[j] == 0) {
        if (((num[j]) >> i) % 2 == 1) {
          cnt++;
        }
      }
    }
    if (cnt >= k) {
      ans += (long long)1 << i;
      for (int j = 0; j < num.size(); j++) {
        if (((num[j]) >> i) % 2 == 0) {
          usable[j] = 1;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
