#include <bits/stdc++.h>
using namespace std;
const int N = 55;
long long a[N];
long long sum[N][N];
int n, k;
bool dp[N][N];
bool solve(long long X) {
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= n; j++) dp[i][j] = 0;
  dp[0][0] = 1;
  for (int it = 0; it < k; it++)
    for (int i = 0; i < n; i++) {
      if (!dp[it][i]) continue;
      for (int j = i + 1; j <= n; j++)
        if ((sum[i][j] & X) == X) dp[it + 1][j] = 1;
    }
  return dp[k][n];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int l = 0; l < n; l++)
    for (int r = l + 1; r <= n; r++) {
      sum[l][r] = 0;
      for (int i = l; i < r; i++) sum[l][r] += a[i];
    }
  long long ans = 0;
  for (int i = 60; i >= 0; i--) {
    ans ^= 1LL << i;
    if (!solve(ans)) ans ^= 1LL << i;
  }
  printf("%lld\n", ans);
  return 0;
}
