#include <bits/stdc++.h>
using namespace std;
const int N = 60;
int n, k;
long long a[N];
long long s[N];
vector<int> g[N][N], c[N][N];
bool f[N][N];
bool ok(int value) {
  memset(f, false, sizeof(f));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (j == 1) {
        if ((s[i] & (1ll << value))) {
          f[i][j] = true;
        }
      } else {
        for (int id = 0; id < (int)g[i][j].size(); id++) {
          int pos = g[i][j][id];
          if (f[pos][j - 1] && ((s[i] - s[pos]) & (1ll << value))) {
            f[i][j] = true;
            c[i][j].push_back(pos);
          }
        }
      }
    }
  }
  if (f[n][k]) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        g[i][j].clear();
        for (int id = 0; id < (int)c[i][j].size(); id++) {
          g[i][j].push_back(c[i][j][id]);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      c[i][j].clear();
    }
  }
  return f[n][k];
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      for (int z = 0; z < i; z++) {
        g[i][j].push_back(z);
      }
    }
  }
  for (int i = N; i >= 0; i--) {
    if (ok(i)) {
      res += (1LL << i);
    }
  }
  cout << res;
  return 0;
}
