#include <bits/stdc++.h>
using namespace std;
using UINT64 = unsigned long long;
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<UINT64> a;
  for (int i = 0; i < n; i++) {
    int j;
    cin >> j;
    a.emplace_back(j);
  }
  vector<UINT64> v;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      UINT64 sum = accumulate(a.begin() + j, a.begin() + j + i, 0ULL);
      v.emplace_back(sum);
    }
  }
  sort(v.rbegin(), v.rend());
  UINT64 ans = 0;
  for (int m = 40; m >= 0; m--) {
    UINT64 t2 = 1ULL << m;
    int cnt = 0;
    int vs = v.size();
    for (int s = 0; s < vs; s++) {
      if (((ans + t2) & v[s]) == (ans + t2)) {
        cnt++;
        if (cnt == k) {
          ans += t2;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
