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

def delivable(m):
    loading=0
    track_num=1
    for i in range(n):
        if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
    if track_num <= k:
        return True
    else:
        return False


r=1000000000
l=min(w)-1
while r-l > 1:
    m=(r+l)//2
    if delivable(m):
        r=m
    else:
        l=m

print(r)
 n,k=map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k w=[0]*n w [0]*n [0] 0 n for i in range(n):
    w[i]=int(input()) i range(n) range n w[i]=int(input()) w[i] w i int(input()) int input() input def delivable(m):
    loading=0
    track_num=1
    for i in range(n):
        if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
    if track_num <= k:
        return True
    else:
        return False delivable loading=0 loading 0 track_num=1 track_num 1 for i in range(n):
        if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
     i range(n) range n if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
     w[i] > m w[i] w i m return False False break loading += w[i] loading w[i] w i if loading > m:
                loading=w[i]
                track_num += 1
     loading > m loading m loading=w[i] loading w[i] w i track_num += 1 track_num 1 if track_num <= k:
        return True
    else:
        return False track_num <= k track_num k return True True return False False m m r=1000000000 r 1000000000 l=min(w)-1 l min(w)-1 min(w) min w 1 while r-l > 1:
    m=(r+l)//2
    if delivable(m):
        r=m
    else:
        l=m r-l > 1 r-l r l 1 m=(r+l)//2 m (r+l)//2 r+l r l 2 if delivable(m):
        r=m
    else:
        l=m delivable(m) delivable m r=m r m l=m l m print(r) print r r=1000000000 1000000000 r k=map(int, input().split()) map(int, input().split()) k m=(r+l)//2 (r+l)//2 m l=min(w)-1 min(w)-1 l n,k=map(int, input().split()) map(int, input().split()) n def delivable(m):
    loading=0
    track_num=1
    for i in range(n):
        if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
    if track_num <= k:
        return True
    else:
        return False def delivable(m):
    loading=0
    track_num=1
    for i in range(n):
        if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
    if track_num <= k:
        return True
    else:
        return False delivable w=[0]*n [0]*n w r=m m r l=m m l
n,k=map(int, input().split())
w=[0]*n
for i in range(n):
    w[i]=int(input())

def delivable(m):
    loading=0
    track_num=1
    for i in range(n):
        if w[i] > m:
            return False
            break
        else:
            loading += w[i] 
            if loading > m:
                loading=w[i]
                track_num += 1
    if track_num <= k:
        return True
    else:
        return False


r=1000000000
l=min(w)-1
while r-l > 1:
    m=(r+l)//2
    if delivable(m):
        r=m
    else:
        l=m

print(r)

