#include <bits/stdc++.h>
using namespace std;
long long int a[109], pre[109], ans = 0;
int dp[109][109], n, k;
bool possible(long long int mask) {
  int i, j, t1, t2, t3, t4;
  long long int buf1, buf2, buf3, buf4;
  memset(dp, -1, sizeof(dp));
  for (i = 1; i <= n; i++) {
    if ((mask & pre[i]) == mask) {
      dp[i][1] = 1;
    }
  }
  for (i = 2; i <= k; i++) {
    for (j = 1; j <= n; j++) {
      for (t1 = j - 1; t1 >= 1; t1--) {
        buf1 = pre[j] - pre[t1];
        if (dp[t1][i - 1] != 1) {
          continue;
        }
        if ((buf1 & mask) == mask) {
          dp[j][i] = 1;
        }
      }
    }
  }
  return (dp[n][k] == 1);
}
int main() {
  int i, j, t1, t2, t3, t4;
  long long int buf1, buf2, buf3, mask = 0;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + a[i];
  }
  for (i = 58; i >= 0; i--) {
    mask |= (1ll << i);
    if (possible(mask)) {
      ans += (1ll << i);
    } else {
      mask ^= (1ll << i);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
