#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
struct CRT {
    vector<pair<ll, ll>> v;
    void add(ll a, ll m) { v.push_back({ a, m }); } // x = a (mod m)

    set<ll> enumpr(ll n) { set<ll> V;
        for (ll i = 2; i*i <= n; i++) while (n%i == 0) V.insert(i), n /= i;
        if (n>1) V.insert(n); return V; }
    ll ext_gcd(ll p, ll q, ll& x, ll& y) {
        if (q == 0) return x = 1, y = 0, p; ll g = ext_gcd(q, p%q, y, x); y -= p / q*x; return g; }
    ll inv(ll p, ll q) { ll xx, yy, g = ext_gcd(p, q, xx, yy); if (xx<0) xx += q, yy -= p; return xx; }

    ll solve(ll mo = 1010101010101LL) {
        string s; int N = v.size(); set<ll> P; vector<int> num;
        rep(i, 0, N) { set<ll> S = enumpr(v[i].second); for(ll r : S) P.insert(r);}
        num = vector<int>(N, 0);
        for(ll r : P) { int y = 0;
            rep(x, 0, N) { num[x] = 1; int j = v[x].second; while (j%r == 0) j /= r, num[x] *= r;
                if (num[y]<num[x]) y = x; }
            rep(x, 0, N) if (x != y) {
                if (v[x].first%num[x] != v[y].first%num[x]) return -1;
                v[x].second /= num[x]; v[x].first %= v[x].second; } }
        vector<pair<ll, ll> > V2;
        rep(x, 0, N) if (v[x].second>1) V2.emplace_back(v[x].second, v[x].first);
        sort(V2.begin(), V2.end()); v = V2; N = v.size();
        rep(y, 0, N) rep(x, 0, y) { ll k = v[y].second - v[x].second; if (k<0) k += v[y].first;
            v[y].second = k*inv(v[x].first, v[y].first) % v[y].first; }
        ll ret = 0; for (int x = N - 1; x >= 0; x--) ret = (ret*v[x].first + v[x].second) % mo;
        return ret;
    }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/







int N, K; ll A[1010];
ll sm[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    sm[0] = A[0];
    rep(i, 1, N) sm[i] = sm[i - 1] + A[i];

    vector<ll> v;
    rep(l, 0, N) rep(r, l, N) {
        ll tot = sm[r];
        if (l) tot -= sm[l - 1];
        v.push_back(tot);
    }
    int n = v.size();
    vector<int> ok(n, 1);

    ll ans = 0;
    rrep(d, 60, 0) {
        ll msk = 1LL << d;
        int cnt = 0;
        rep(i, 0, n) if (v[i] & msk and ok[i]) cnt++;
        if (K <= cnt) {
            ans += msk;
            rep(i, 0, n) if (!(v[i] & msk) and ok[i]) ok[i] = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6512