#include <bits/stdc++.h>
// #include "/usr/local/include/cxx_pretty_print/cxx_pretty_print.hpp"

using namespace std;
/* type aliases */
using i32 = int32_t; using ui32 = uint32_t; using i64 = int64_t; using ui64 = uint64_t; using i128 = __int128;
using f32 = float;   using f64  = double;   using f80 = long double;
using PII = pair<i32, i32>; using PLL = pair<i64, i64>; using PFF = pair<f32, f32>; using PDD = pair<f64, f64>;
using VB  = vector<bool>;   using VS  = vector<string>;
using VI  = vector<i32>;    using VL  = vector<i64>;    using VF  = vector<f32>;    using VD  = vector<f64>;
using VVI = vector<VI>;     using VVL = vector<VL>;     using VVF = vector<VF>;     using VVD = vector<VD>;
using VPI = vector<PII>;    using VPL = vector<PLL>;    using VPF = vector<PFF>;    using VPD = vector<PDD>;
/* constants */
constexpr i64 mod = 1000000007;                                // 10^9+7
constexpr i64 inf = 9000000000000000000;                       // 9*10^18
/* macros */
#define MAX(c)        *max_element(ALL(c))
#define MIN(c)        *min_element(ALL(c))
#define SIZE(c)       (i64)((c).size())                        // unsined int (size_t) -> int64_t
#define ALL(c)        (c).begin(), (c).end()
#define RALL(c)       (c).rbegin(), (c).rend()
#define REP(i, n)     for (i64 i=0; i<(n); ++i)           // 0 to n-1
#define FOR(i, a, b)  for (i64 i=(a); i<(b); ++i)         // a to b-1
#define REPD(i, n)    for (i64 i=(n)-1; i>=0; --i)        // n-1 to 0
/* debug */
#define debug(x)      cerr << #x << ": " << (x) << '\n'
#define debugvec(v)   for (size_t _ = 0; _ < (v).size(); ++_) {cerr << #v << '[' << _ << "]: " << (v)[_] << '\n';}
i64 randint(i64 a, i64 b) {return a + (i64)(rand() * (b - a + 1.0) / (1.0 + RAND_MAX));}
/* useful output */
auto print = [](auto x) {cout << (x) << '\n';};
template <class T> void printvec(T v, string sep=" ", string end="\n") {REP(i, SIZE(v)-1) cout << v[i] << sep; cout << v[SIZE(v)-1] << end;}
/* useful input */
VS splitstr(string s, char delim=' ') {VS v; string buf; stringstream ss{s}; while (getline(ss, buf, delim)) v.push_back(buf); return v;}


bool check_d_flag_will_be_on(VL& beauty, VB& candidate, i64 d, i64 k) {
    i32 cnt{};
    REP(i, SIZE(candidate)) {
        if (candidate.at(i) && (beauty.at(i) & ((i64)1 << d))) ++cnt; 
    }
    // debug(d);
    // debug(cnt);
    return cnt >= k;
}


void update_candidate(VL& beauty, VB& candidate, i64 d) {
    REP(i, SIZE(candidate)) {
        if (candidate.at(i) && !(beauty.at(i) & ((i64)1 << d))) candidate.at(i) = false;
    }
}


void Main() {
    i64 n, k;
    cin >> n >> k;
    VL L(n), ac(n + 1, 0);
    REP(i, n) cin >> L.at(i);
    partial_sum(ALL(L), ++ac.begin());

    VL beauty;
    beauty.reserve(n * (n + 1) / 2);
    for (i32 i = 0; i <= n; ++i) {
        for (i32 j = i + 1; j <= n; ++j) {
            beauty.push_back(ac[j] - ac[i]);
        }
    }



    i64 ans{};
    VB candidate(SIZE(beauty), true);
    for (i64 d = 63; d >= 0; --d) {
        if (check_d_flag_will_be_on(beauty, candidate, d, k)) {
            update_candidate(beauty, candidate, d);
            ans += ((i64)1 << d);
        }
        // debug(ans);
    }
    print(ans);

}


signed main() {
    cin.tie(nullptr);                                         // cin と cout の tie を切り高速化
    cout << fixed << setprecision(15);                        // 浮動小数点数が 1e-006 のように表示されることを防ぐ
    Main();
}

Measured memory_bytes: 7116