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

def track_search(mid):
    count_track = 1
    cnt = 0
    for i in w:
        if i+cnt<=mid:
            cnt+=i
        else:
            count_track += 1
            cnt = i
    return count_track


def weight_search():
    global ans
    right = sum(w)+1
    left = max(w)
    while right>left:
        mid = (right+left)//2
        track = track_search(mid)
        if track>k:
            left = mid+1
        else:
            right = mid
            ans = mid
    return ans

print(weight_search()) 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 track_search(mid):
    count_track = 1
    cnt = 0
    for i in w:
        if i+cnt<=mid:
            cnt+=i
        else:
            count_track += 1
            cnt = i
    return count_track track_search count_track = 1 count_track 1 cnt = 0 cnt 0 for i in w:
        if i+cnt<=mid:
            cnt+=i
        else:
            count_track += 1
            cnt = i
     i w if i+cnt<=mid:
            cnt+=i
        else:
            count_track += 1
            cnt = i
     i+cnt<=mid i+cnt i cnt mid cnt+=i cnt i count_track += 1 count_track 1 cnt = i cnt i return count_track count_track mid mid def weight_search():
    global ans
    right = sum(w)+1
    left = max(w)
    while right>left:
        mid = (right+left)//2
        track = track_search(mid)
        if track>k:
            left = mid+1
        else:
            right = mid
            ans = mid
    return ans weight_search global ans right = sum(w)+1 right sum(w)+1 sum(w) sum w 1 left = max(w) left max(w) max w while right>left:
        mid = (right+left)//2
        track = track_search(mid)
        if track>k:
            left = mid+1
        else:
            right = mid
            ans = mid
     right>left right left mid = (right+left)//2 mid (right+left)//2 right+left right left 2 track = track_search(mid) track track_search(mid) track_search mid if track>k:
            left = mid+1
        else:
            right = mid
            ans = mid
     track>k track k left = mid+1 left mid+1 mid 1 right = mid right mid ans = mid ans mid return ans ans print(weight_search()) print weight_search() weight_search n,k = map(int, input().split()) map(int, input().split()) n def weight_search():
    global ans
    right = sum(w)+1
    left = max(w)
    while right>left:
        mid = (right+left)//2
        track = track_search(mid)
        if track>k:
            left = mid+1
        else:
            right = mid
            ans = mid
    return ans def weight_search():
    global ans
    right = sum(w)+1
    left = max(w)
    while right>left:
        mid = (right+left)//2
        track = track_search(mid)
        if track>k:
            left = mid+1
        else:
            right = mid
            ans = mid
    return ans weight_search w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w k = map(int, input().split()) map(int, input().split()) k def track_search(mid):
    count_track = 1
    cnt = 0
    for i in w:
        if i+cnt<=mid:
            cnt+=i
        else:
            count_track += 1
            cnt = i
    return count_track def track_search(mid):
    count_track = 1
    cnt = 0
    for i in w:
        if i+cnt<=mid:
            cnt+=i
        else:
            count_track += 1
            cnt = i
    return count_track track_search
n,k = map(int, input().split())
w = [int(input()) for i in range(n)]

def track_search(mid):
    count_track = 1
    cnt = 0
    for i in w:
        if i+cnt<=mid:
            cnt+=i
        else:
            count_track += 1
            cnt = i
    return count_track


def weight_search():
    global ans
    right = sum(w)+1
    left = max(w)
    while right>left:
        mid = (right+left)//2
        track = track_search(mid)
        if track>k:
            left = mid+1
        else:
            right = mid
            ans = mid
    return ans

print(weight_search())
