#include <bits/stdc++.h>
using namespace std;
const long long N = 60;
const long long inf = (long long)1e15;
long long n, k;
long long a[N];
bool dp[N][N];
bool possible(long long target) {
  memset(dp, false, sizeof dp);
  dp[0][k] = true;
  for (long long i = 0; i <= n; i++) {
    for (long long left = k; left >= 1; left--) {
      long long sum = 0;
      for (long long j = i + 1; j <= n; j++) {
        sum += a[j];
        if ((sum & target) == target) {
          dp[j][left - 1] |= dp[i][left];
        }
      }
    }
  }
  return dp[n][0];
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long LG = 60; LG >= 0; LG--) {
    if (possible(ans | (1LL << LG))) ans |= (1LL << LG);
  }
  cout << ans << '\n';
  return 0;
}
