Imports System.Collections.Generic
Imports System.Console
Imports System.Math  
Module Program
 	Sub Main()
        Dim input As String() = Console.ReadLine().Split(" ")
	    Dim N As Integer = input(0)
	    Dim K As Integer = input(1)
 '       Console.Error.WriteLine(N)
'        Console.Error.WriteLine(K)
        
        input = Console.ReadLine().Split(" ")
	    Dim A() As Integer = New Integer(N){}
        For i As Integer = 0 To N-1
            A(i) = input(i)
'        Console.Error.WriteLine(A(i))
        Next
  
  	    Dim cumsum() As Long = New Long(N+1){}
        For i As Integer = 0 To N-1
            cumsum(i+1) = A(i) + cumsum(i)
'        Console.Error.WriteLine(cumsum(i+1))
        Next

        Dim li As New List(Of Long)
        For l As Integer = 0 To N
            For r As Integer = l+1 To N
                li.Add(cumsum(r)-cumsum(l))
            Next
        Next

'For Each v As Long in li
'        Console.Error.WriteLine(v)
'        Next

        Dim max As Long = 0 
        For shift As Integer = 60 To 0 Step -1
            If shift < 0 Then
                Exit For
            End If
            Dim one As Long = 1
            Dim mask As Long = one<<shift 
            Console.Error.WriteLine(mask)
            Dim count As Integer = 0
            For Each v As Long in li
                If (v And mask) <> 0 Then
                    count+=1
                End If
            Next

            If count >= K Then
                max = max Or mask
                Dim tmp As New List(Of Long)
                For Each v As Long in li
                    If (v And mask) <> 0 Then
                        tmp.Add(v)
                    End If
                Next
                li.Clear()
                For Each v As Long in tmp
                    li.Add(v)
                Next
            End If
        Next
        Console.WriteLine(max)
    End Sub
End Module
