n,k=map(int, input("").split(" "))
w=[]
for i in range(n):
    w.append(int(input("")))
s=sum(w)
m=max(w)
while s>m:
    a=0
    b=0
    tmp=int((s+m)/2)
    for i in w:
        a+=i
        if a>tmp:
            a=i
            b+=1
    if b>=k:
        m=tmp+1
    else:
        s=tmp
print(m) n,k=map(int, input("").split(" ")) n map(int, input("").split(" ")) map int input("").split(" ") ("").split ("") input "" split " " k w=[] w [] for i in range(n):
    w.append(int(input(""))) i range(n) range n w.append(int(input(""))) w.append w append int(input("")) int input("") input "" s=sum(w) s sum(w) sum w m=max(w) m max(w) max w while s>m:
    a=0
    b=0
    tmp=int((s+m)/2)
    for i in w:
        a+=i
        if a>tmp:
            a=i
            b+=1
    if b>=k:
        m=tmp+1
    else:
        s=tmp s>m s m a=0 a 0 b=0 b 0 tmp=int((s+m)/2) tmp int((s+m)/2) int (s+m)/2 s+m s m 2 for i in w:
        a+=i
        if a>tmp:
            a=i
            b+=1
     i w a+=i a i if a>tmp:
            a=i
            b+=1
     a>tmp a tmp a=i a i b+=1 b 1 if b>=k:
        m=tmp+1
    else:
        s=tmp b>=k b k m=tmp+1 m tmp+1 tmp 1 s=tmp s tmp print(m) print m s=sum(w) sum(w) s m=max(w) max(w) m s=tmp tmp s a+=i i a tmp=int((s+m)/2) int((s+m)/2) tmp b+=1 1 b b=0 0 b k=map(int, input("").split(" ")) map(int, input("").split(" ")) k m=tmp+1 tmp+1 m w=[] [] w a=0 0 a n,k=map(int, input("").split(" ")) map(int, input("").split(" ")) n a=i i a
n,k=map(int, input("").split(" "))
w=[]
for i in range(n):
    w.append(int(input("")))
s=sum(w)
m=max(w)
while s>m:
    a=0
    b=0
    tmp=int((s+m)/2)
    for i in w:
        a+=i
        if a>tmp:
            a=i
            b+=1
    if b>=k:
        m=tmp+1
    else:
        s=tmp
print(m)
