#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
#define fi first
#define se second
#define N 100005
#define debug(x) cerr<<#x<<"="<<x<<endl
#define MP(x,y) make_pair(x,y)
#define LL long long
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
class BigInteger { public:
int size,num[1000];

    BigInteger()
        {
            size=0;
            memset(num,0,sizeof(num));
        }
    BigInteger(int data)
        {
            size=0;
            while (data!=0)
            {
                size++;
                num[size]=data%10;
                data=data/10;
            }
        }
    void init(int data)
        {
            size=0;
            while (data!=0)
            {
                size++;
                num[size]=data%10;
                data=data/10;
            }
        }
};
BigInteger operator + (BigInteger A,BigInteger B)
{
    BigInteger Ans;
    int s=max(A.size,B.size);
    Ans.size=s;
    for (int i=1;i<=s;i++)
        Ans.num[i]=A.num[i]+B.num[i];
    for (int i=1;i<=s;i++)
        if (Ans.num[i]>=10)
        {
            Ans.num[i+1]+=Ans.num[i]/10;
            Ans.num[i]=Ans.num[i]%10;
        }
    if (Ans.num[s+1]!=0)
        Ans.size++;
    return Ans;
}
BigInteger operator - (BigInteger A,BigInteger B)
{
    BigInteger Ans;
    int s=max(A.size,B.size);
    Ans.size=s;
    for (int i=1;i<=s;i++)
        Ans.num[i]=A.num[i]-B.num[i];
    for (int i=1;i<=s;i++)
        if (Ans.num[i]<0)
        {
            Ans.num[i+1]-=Ans.num[i]/10;
            Ans.num[i]=Ans.num[i]%10;
        }
    if (Ans.num[s+1]!=0)
        Ans.size++;
    return Ans;
}
ostream & operator << (ostream &os,BigInteger A)
{
    int s=A.size;
    for (int i=s;i>=1;i--)
        os<<A.num[i];
    return os;
}
BigInteger operator * (BigInteger A,BigInteger B)
{
    BigInteger Ans;
    int s1=A.size,s2=B.size;
    for (int i=1;i<=s1;i++)
        for (int j=1;j<=s2;j++)
            Ans.num[i+j-1]+=A.num[i]*B.num[j];
    int s=s1+s2-1;
    int k=1;
    while ((Ans.num[k]!=0)||(k<=s))
    {
        Ans.num[k+1]+=Ans.num[k]/10;
        Ans.num[k]=Ans.num[k]%10;
        k++;
    }
    if (Ans.num[k]==0)
        k--;
    Ans.size=k;
    return Ans;
}
typedef pair<int,int> pii;
typedef long double Double;
struct Vector
{
    double x,y;
    Vector(double X=0,double Y=0)
    {
        x=X,y=Y;
    }
    void Print(string name)
    {
        debug(name);
        cout<<x<<' '<<y<<endl;
        cout<<endl;
    }
};


typedef Vector Point;
typedef vector<Point> Polygon;


const double pi= acos(-1.0);
Vector operator + (Vector A,Vector B) {return ((Vector){A.x+B.x,A.y+B.y});}
Vector operator - (Vector A,Vector B) {return ((Vector){A.x-B.x,A.y-B.y});}
Vector operator * (Vector A,double p) {return ((Vector){A.x*p,A.y*p});}
Vector operator / (Vector A,double p) {return ((Vector){A.x/p,A.y/p});}

bool operator < (const Vector& a,const Vector& b)
{
    return a.x<b.x||(a.x==b.x&&a.y<b.y);
}

const double eps=1e-8;
int dcmp(double x)
{
    if(fabs(x)<eps) return 0;
    else return x<0? -1:1;
}

bool operator == (const Vector& a,const Vector& b)
{
    return dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0;
}

double Dot(Vector A,Vector B)
{
    return A.x*B.x+A.y*B.y;
}

double Len(Vector A)
{
    return sqrt(Dot(A,A));
}

double Angle(Vector A,Vector B)
{
    return acos(Dot(A,B)/Len(A)/Len(B));
}

double Cross(Vector A,Vector B)
{
    return A.x*B.y-A.y*B.x;
}

double Area2(Point A,Point B,Point C)
{
    return Cross(B-A,C-A);
}

Vector Rotate(Vector A,double rad)  //counter-clockwise
{
    return ((Vector){A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad)});
}

Vector Normal(Vector A) //Unit normal vector 单位法向量，A应是非零向量
{
    double L=Len(A);
    return Vector(-A.y/L,A.x/L);
}

struct Line
{
    Point P;
    Vector v;
    double ang;
    Line() {}
    Line(Point P,Vector v):P(P),v(v)
    {
        ang=atan2(v.y,v.x);
    }
    bool operator<(const Line &L) const
    {
        return ang<L.ang;
    }
};

bool OnLeft(Line L,Point p)
{
    return dcmp(Cross(L.v,p-L.P))>=0; //?????
}

Point GLI(Point P,Vector v,Point Q,Vector w)
{
    Vector u=P-Q;
    double t=Cross(w,u)/Cross(v,w);
    return P+v*t;
}

Point GLI(Line a,Line b)
{
    Vector u=a.P-b.P;
    double t=Cross(b.v,u)/Cross(a.v,b.v);
    return a.P+a.v*t;
}

double DisTL(Point P,Point A,Point B)
{
    Vector v1=B-A,v2=P-A;
    return fabs(Cross(v1,v2)/Len(v1));
}

double DisTS(Point P,Point A,Point B)
{
    if(A==B) return Len(P-A);
    Vector v1=B-A, v2=P-A, v3=P-B;
    if(dcmp(Dot(v1,v2))<0) return Len(v2);
    else if(dcmp(Dot(v1,v3))>0) return Len(v3);
    else return fabs(Cross(v1,v2))/Len(v1);
}

bool OnSegment(Point P,Point A,Point B)
{
    return dcmp(DisTL(P,A,B))==0&&dcmp(Dot(P-A,P-B))<0&&!(P==A)&&!(P==B);
}

double PolygonArea(Point* p,int n)
{
    double area=0;
    for(int i=1;i<n-1;i++)
        area+=Cross(p[i]-p[0],p[i+1]-p[0]);
    return area/2;
}

double PolygonArea(Polygon p)
{
    double area=0;
    int n=p.size();
    for(int i=1;i<n-1;i++)
        area+=Cross(p[i]-p[0],p[i+1]-p[0]);
    return area/2;
}

int PInP(Point p,Point* poly,int n)
{
    int wn=0,k,d1,d2;
    for(int i=0;i<n;i++)
    {
        if(dcmp(DisTS(p,poly[i],poly[(i+1)%n])==0)) return -1;
        k=dcmp(Cross(poly[(i+1)%n]-poly[i],p-poly[i]));
        d1=dcmp(poly[i].y-p.y);
        d2=dcmp(poly[(i+1)%n].y-p.y);
        if(k>0&&d1<=0&&d2>0) wn++;
        if(k<0&&d2<=0&&d1>0) wn--;
    }
    if(wn) return 1;
    else return 0;
}

int ConvexHull(Point* p,int n,Point* ch) //have no three point on one line
{
    sort(p,p+n);
    int k,i,m=0;
    for(i=0;i<n;i++)
    {
        while(m>1&&dcmp(Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2]))<=0) m--;
        ch[m++]=p[i];
    }
    k=m;
    for(i=n-2;i>=0;i--)
    {
        while(m>k&&dcmp(Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2]))<=0) m--;
        ch[m++]=p[i];
    }
    if(n>1) m--;
    return m;
}

double Rotating_calipers(Point* ch,int n) //calculate the furthest pair of point
{
    if(n==1)
        return 0;
    if(n==2)
        return Len(ch[0]-ch[1]);
    int now=1,i;
    double ans=0;
    ch[n]=ch[0];
    for(i=0;i<n;i++)
    {
        while(dcmp(DisTL(ch[now],ch[i],ch[i+1])-DisTL(ch[now+1],ch[i],ch[i+1]))<=0)
            now=(now+1)%n;
        ans=max(ans,Len(ch[now]-ch[i]));
        ans=max(ans,Len(ch[now]-ch[i+1]));
    }
    return ans;
}

double Rotating_calipers2(Point* p,Point* q,int n,int m) //calculate the minimal distance between to convexhull
// must use this function twice
{
    int x=0,y=0,i;
    double ans=1e10,t;
    for(i=0;i<n;i++)
        x=(p[i].y<p[x].y)?i:x;
    for(i=0;i<m;i++)
        y=(q[i].y<q[y].y)?i:y;
    p[n]=p[0];
    q[m]=q[0];
    for(i=0;i<n;i++)
    {
        while((t=dcmp(Cross(p[x]-p[x+1],q[y+1]-q[y])))<0)
            y=(y+1)%m;
        if(t==0)
        {
            ans=min(ans,DisTS(p[x],q[y+1],q[y]));
            ans=min(ans,DisTS(p[x+1],q[y+1],q[y]));
            ans=min(ans,DisTS(q[y],p[x],p[x+1]));
            ans=min(ans,DisTS(q[y+1],p[x],p[x+1]));
        }
        else
            ans=min(ans,DisTS(q[y],p[x],p[x+1]));
        x=(x+1)%n;
    }
    return ans;
}

Polygon CutPolygon(Polygon poly,Point A,Point B)  //get the left of A->B
{
    Polygon newpoly;
    Point C,D,ip;
    int n=poly.size(),i;
    for(i=0;i<n;i++)
    {
        C=poly[i];
        D=poly[(i+1)%n];
        if(dcmp(Cross(B-A,C-A))>=0)
            newpoly.push_back(C);
        if(dcmp(Cross(B-A,D-C))!=0)
        {
            ip=GLI(A,B-A,C,D-C);
            if(OnSegment(ip,C,D))
                newpoly.push_back(ip);
        }
    }
    return newpoly;
}

void InitPolygon(Polygon &poly,double inf)
{
    poly.clear();
    poly.push_back((Point){-inf,-inf});
    poly.push_back((Point){inf,-inf});
    poly.push_back((Point){inf,inf});
    poly.push_back((Point){-inf,inf});
}
int Halfplane_Intersection(Line* L,int n,Point* poly);
Point Center_of_gravity(Point A,Point B,Point C);
double Min_Cover_Circle(Point *p,int n,Point &c);
const int MAX=1e6+5;
int n,k,tot;
LL a[MAX];
LL qwq[2][MAX];
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n; ++i)
		scanf("%lld",&a[i]);
	for(int i=1; i<=n; ++i) {
		LL sum=0;
		for(int j=i; j<=n; ++j)
			qwq[0][++tot]=sum+=a[j];
		}
	LL tt=tot,fl=1,cnt=0,ans=0;
	for(LL i=63; i>=0; --i) {
		fl^=1,cnt=0;
		for(int j=1; j<=tt; ++j)
			if(qwq[fl][j]&(1ll<<i)) qwq[fl^1][++cnt]=qwq[fl][j];
		if(cnt>=k) ans+=(1ll<<i),tt=cnt;
		else for(int j=1; j<=tt; ++j)
				qwq[fl^1][j]=qwq[fl][j];
		}
	return printf("%lld",ans),0;
	}
double Min_Cover_Circle(Point *p,int n,Point &c)
{
    random_shuffle(p,p+n);
    c=p[0];
    double r=0;
    int i,j,k;
    for(i=1;i<n;i++)
        if(dcmp(Len(c-p[i])-r)>0)
        {
            c=p[i],r=0;
            for(j=0;j<i;j++)
                if(dcmp(Len(c-p[j])-r)>0)
                {
                    c=(p[i]+p[j])/2;
                    r=Len(c-p[i]);
                    for(k=0;k<j;k++)
                        if(dcmp(Len(c-p[k])-r)>0)
                        {
                            c=Center_of_gravity(p[i],p[j],p[k]);
                            r=Len(c-p[i]);
                        }
                }
        }
    return r;
}
Point Center_of_gravity(Point A,Point B,Point C)
{
    Point P=(A+B)/2,Q=(A+C)/2;
    Vector v=Rotate(B-A,pi/2),w=Rotate(C-A,pi/2);
    if(dcmp(Len(Cross(v,w)))==0)//这是三点一线的情况
    {
        if(dcmp(Len(A-B)+Len(B-C)-Len(A-C))==0)
            return (A+C)/2;
        if(dcmp(Len(A-C)+Len(B-C)-Len(A-B))==0)
            return (A+B)/2;
        if(dcmp(Len(A-B)+Len(A-C)-Len(B-C))==0)
            return (B+C)/2;
    }
    return GLI(P,v,Q,w);
}
int Halfplane_Intersection(Line* L,int n,Point* poly)
{
    sort(L,L+n);

    int first,last,i;
    Point *p=new Point[n];
    Line *q=new Line[n];
    q[first=last=0]=L[0];
    for(i=1;i<n;i++)
    {
        while(first<last&&!OnLeft(L[i],p[last-1]))
            last--;
        while(first<last&&!OnLeft(L[i],p[first]))
            first++;
        q[++last]=L[i];
        if(dcmp(Cross(q[last].v,q[last-1].v)/Len(q[last].v))==0)
        {
            last--;
            if(OnLeft(q[last],L[i].P))
                q[last]=L[i];
        }
        if(first<last)
            p[last-1]=GLI(q[last-1],q[last]);
    }
    while(first<last&&!OnLeft(q[first],p[last-1]))
        last--;
    if(last-first<=1) return 0;
    p[last]=GLI(q[last],q[first]);

    int m=0;
    for(i=first;i<=last;i++) poly[m++]=p[i];
    return m;
}

Measured memory_bytes: 12544