n,k=map(int,input().split())
w=[int(input())for i in range(n)]

def check(x):
    global w
    global n,k
    track=0
    now=0
    for i in w:
        if i>x:
            return False
        if now+i>x:
            track+=1
            now=i
        else:
            now+=i
    if now>0:
        track+=1
    if track>k:
        return False
    else:
        return True
amax=1000000000
amin=0
while amin+1!=amax:
    amid=(amax+amin)//2
    if check(amid):
        amax=amid
    else:
        amin=amid
    
print(amax) n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k int(input())for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input w=[int(input())for i in range(n)] w [int(input())for i in range(n)] def check(x):
    global w
    global n,k
    track=0
    now=0
    for i in w:
        if i>x:
            return False
        if now+i>x:
            track+=1
            now=i
        else:
            now+=i
    if now>0:
        track+=1
    if track>k:
        return False
    else:
        return True check global w global n,k track=0 track 0 now=0 now 0 for i in w:
        if i>x:
            return False
        if now+i>x:
            track+=1
            now=i
        else:
            now+=i
     i w if i>x:
            return False
         i>x i x return False False if now+i>x:
            track+=1
            now=i
        else:
            now+=i
     now+i>x now+i now i x track+=1 track 1 now=i now i now+=i now i if now>0:
        track+=1
     now>0 now 0 track+=1 track 1 if track>k:
        return False
    else:
        return True track>k track k return False False return True True x x amax=1000000000 amax 1000000000 amin=0 amin 0 while amin+1!=amax:
    amid=(amax+amin)//2
    if check(amid):
        amax=amid
    else:
        amin=amid
     amin+1!=amax amin+1 amin 1 amax amid=(amax+amin)//2 amid (amax+amin)//2 amax+amin amax amin 2 if check(amid):
        amax=amid
    else:
        amin=amid
     check(amid) check amid amax=amid amax amid amin=amid amin amid print(amax) print amax k=map(int,input().split()) map(int,input().split()) k amin=amid amid amin def check(x):
    global w
    global n,k
    track=0
    now=0
    for i in w:
        if i>x:
            return False
        if now+i>x:
            track+=1
            now=i
        else:
            now+=i
    if now>0:
        track+=1
    if track>k:
        return False
    else:
        return True def check(x):
    global w
    global n,k
    track=0
    now=0
    for i in w:
        if i>x:
            return False
        if now+i>x:
            track+=1
            now=i
        else:
            now+=i
    if now>0:
        track+=1
    if track>k:
        return False
    else:
        return True check amax=amid amid amax amax=1000000000 1000000000 amax n,k=map(int,input().split()) map(int,input().split()) n amid=(amax+amin)//2 (amax+amin)//2 amid w=[int(input())for i in range(n)] [int(input())for i in range(n)] w amin=0 0 amin
n,k=map(int,input().split())
w=[int(input())for i in range(n)]

def check(x):
    global w
    global n,k
    track=0
    now=0
    for i in w:
        if i>x:
            return False
        if now+i>x:
            track+=1
            now=i
        else:
            now+=i
    if now>0:
        track+=1
    if track>k:
        return False
    else:
        return True
amax=1000000000
amin=0
while amin+1!=amax:
    amid=(amax+amin)//2
    if check(amid):
        amax=amid
    else:
        amin=amid
    
print(amax)
