#include <bits/stdc++.h>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, k, a[1000 + 100], ke[1000 * (1000 + 1) / 2 + 100], ke_cou = 0,
                                                                  add;
  long long ans = 0, want, cou = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    ke[ke_cou++] = a[i];
    add = a[i];
    for (int j = i + 1; j < n; j++) {
      add += a[j];
      ke[ke_cou++] = add;
    }
  }
  for (int i = 45; i >= 0; i--) {
    want = ans | (1LL << i);
    cou = 0;
    for (int j = 0; j < ke_cou; j++) {
      if ((want & ke[j]) == want) cou++;
    }
    if (cou >= k) ans = want;
  }
  cout << ans << "\n";
  return 0;
}
