#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
int N, K;
long long sum[MAXN];
bool dp[MAXN][MAXN];
bool check(long long x) {
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int k = 1; k <= K; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j < i; j++) {
        if (((sum[i] - sum[j]) & x) == x) dp[i][k] |= dp[j][k - 1];
      }
    }
  }
  return dp[N][K];
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%lld", &sum[i]);
    sum[i] += sum[i - 1];
  }
  long long ans = 0;
  for (int i = 60; i >= 0; i--) {
    long long t = ans | (1LL << i);
    if (check(t)) ans = t;
  }
  printf("%lld\n", ans);
  return 0;
}
