#include <bits/stdc++.h>
using namespace std;
int a[1005];
long long pre[1005];
int b[40];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
  }
  long long ans = 0;
  vector<long long> v;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n - i + 1; j++) {
      v.push_back(pre[i + j - 1] - pre[i - 1]);
    }
  }
  for (int i = 39; i >= 0; i--) {
    vector<long long> temp;
    for (int j = 0; j < v.size(); j++) {
      if ((1LL << i) & v[j]) {
        temp.push_back(v[j]);
      }
    }
    if (temp.size() >= k) {
      ans |= (1LL << i);
      v = temp;
    }
  }
  cout << ans;
}
