#include <bits/stdc++.h>
using namespace std;
int n, k;
long long a[55], ans;
bool f[55][55];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (long long bit = 1ll << 60; bit; bit >>= 1) {
    memset(f, false, sizeof f);
    f[0][0] = true;
    for (int i = 1; i <= k; i++)
      for (int j = i; j <= n; j++) {
        if (!f[i - 1][j - 1]) continue;
        long long sum = 0;
        for (int x = j; x <= n; x++) {
          sum += a[x];
          if ((sum & (ans ^ bit)) == (ans ^ bit)) f[i][x] = true;
        }
      }
    if (f[k][n]) ans ^= bit;
  }
  cout << ans;
}
