#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ch = char;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge {
  ll to, cost;
};
struct edge2 {
  ll from, to, cost;
};
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  ll sum = 0;
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<ll> NA(N * (N + 1) / 2);
  int now = 0;
  for (ll i = 0; i < N; i++) {
    int nowa = A[i];
    int j = i;
    while (j < N) {
      NA[now] = nowa;
      now++;
      j++;
      if (j < N) {
        nowa += A[j];
      }
    }
  }
  ll ans = 0;
  for (ll i = 50; i >= 0; i--) {
    ll res = ans + pow(2, i) + 1e-6, cnt = 0;
    cerr << res << endl;
    for (ll i = 0; i < N * (N + 1) / 2; i++) {
      if ((NA[i] | res) == NA[i]) {
        cnt++;
      }
    }
    if (cnt >= K) {
      ans = res;
    }
  }
  cout << ans << endl;
}
