#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int, greater<long long int>> yz;
vector<pair<long long int, string>> a1;
vector<pair<long long int, long long int>> a2;
vector<pair<long long int, pair<long long int, long long int>>> a3;
vector<long long int> ary[100005];
bool isSubSequence(string str1, string str2, long long int m, long long int n) {
  if (m == 0) return true;
  if (n == 0) return false;
  if (str1[m - 1] == str2[n - 1])
    return isSubSequence(str1, str2, m - 1, n - 1);
  return isSubSequence(str1, str2, m, n - 1);
}
long long int fac[5015];
void output2(long long int t) {
  if (t > 2) {
    cout << "3"
         << " "
         << "1"
         << "\n";
    cout << "3"
         << " "
         << "2"
         << "\n";
    for (long long int i = 2; i < t - 1; i++) {
      cout << "3"
           << " " << i + 2 << "\n";
    }
  } else {
    for (long long int i = 0; i < t - 1; i++) {
      cout << "1"
           << " " << i + 2 << "\n";
    }
  }
}
long long int n, k;
long long int arr[30003];
long long int sum[100];
long long int pos[100][100];
long long int check(long long int x) {
  memset(pos, false, sizeof(pos));
  pos[0][0] = true;
  for (long long int i = 1; i <= k; i++) {
    for (long long int r = 1; r <= n; r++) {
      for (long long int l = 0; l < r; l++) {
        if ((pos[l][i - 1]) && (((sum[r] - sum[l]) & x) == x)) {
          pos[r][i] = true;
          break;
        }
      }
    }
  }
  return pos[n][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  sum[0] = 0;
  for (long long int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + arr[i];
  }
  long long int answer = 0;
  for (long long int bit = 62; bit >= 0; bit--) {
    if (check(answer | 1LL << bit)) {
      answer = answer | (1LL << bit);
    }
  }
  cout << answer << "\n";
}
