#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long dp[60][60], sum[60];
bool pd(long long x) {
  memset(dp, 0, sizeof dp);
  dp[0][0] = 1;
  for (long long i = 1; i <= k; i++)
    for (long long j = 1; j <= n; j++)
      for (long long l = 1; l <= j; l++)
        if (((sum[j] - sum[l - 1]) & x) == x && dp[i - 1][l - 1]) dp[i][j] = 1;
  return dp[k][n];
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  long long x;
  for (long long i = 1; i <= n; i++) cin >> x, sum[i] = sum[i - 1] + x;
  long long ans = 0;
  for (long long i = 60; i >= 0; i--) {
    if (pd(ans | (1ll << i))) ans |= (1ll << i);
  }
  cout << ans << endl;
  return 0;
}
