program atcoder
    implicit none
    integer(8),allocatable,dimension(:) :: a,b,c
    integer(8) N,K,i,j,l,m,num
    read*,N,K
    allocate( a(N-1) )
    allocate( b(N*(N+1)/2) )
    allocate( c(N*(N+1)/2) )
    read(*,*)(a(i),i=1,N)
    l = 1
    do i=1,N
        m = 0
        do j=i,N
            m = m + a(j)
            b(l) = m
            l = l + 1
        enddo
    enddo
    !write(*,'(I0)')lshift(1_8,36_8)
    num = N*(N+1)/2
    do i=63,1,-1
        l = 0
        do j=1,num
            if(iand(b(j),lshift(1_8,i))==lshift(1_8,i))then
                l = l+1
                c(l) = b(j)
            endif
        enddo
        if(l>=K)then
            b = c
            num = l
        endif
    enddo
    j = b(1)
    do i=1,num
        j = iand(j,b(i))
    end do
    write(*,'(I0)')j
!----------------------functions--------------------------
contains



end program atcoder