number=list(map(int,input().split()))
count_l=number[0]
count_t=number[1]
luggage=[int(input()) for i in range(count_l)]

min_P=max(max(luggage),sum(luggage)//count_t)
max_P=sum(luggage)
left=min_P
right=max_P

while left<right:
    mid=(left+right)//2
    count_track=1
    flag=1
    load=0
    for i in range(count_l):
        load+=luggage[i]
        if load>mid:
            count_track+=1
            load=luggage[i]

        if count_track>count_t:
            flag=0
            break

    if flag:
        right=mid

    else:
        left=mid+1

print(left)
 number=list(map(int,input().split())) number list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split count_l=number[0] count_l number[0] number 0 count_t=number[1] count_t number[1] number 1 int(input()) for i in range(count_l) for i in range(count_l) i range(count_l) range count_l for i in range(count_l) int(input()) int input() input luggage=[int(input()) for i in range(count_l)] luggage [int(input()) for i in range(count_l)] min_P=max(max(luggage),sum(luggage)//count_t) min_P max(max(luggage),sum(luggage)//count_t) max max(luggage) max luggage sum(luggage)//count_t sum(luggage) sum luggage count_t max_P=sum(luggage) max_P sum(luggage) sum luggage left=min_P left min_P right=max_P right max_P while left<right:
    mid=(left+right)//2
    count_track=1
    flag=1
    load=0
    for i in range(count_l):
        load+=luggage[i]
        if load>mid:
            count_track+=1
            load=luggage[i]

        if count_track>count_t:
            flag=0
            break

    if flag:
        right=mid

    else:
        left=mid+1 left<right left right mid=(left+right)//2 mid (left+right)//2 left+right left right 2 count_track=1 count_track 1 flag=1 flag 1 load=0 load 0 for i in range(count_l):
        load+=luggage[i]
        if load>mid:
            count_track+=1
            load=luggage[i]

        if count_track>count_t:
            flag=0
            break

     i range(count_l) range count_l load+=luggage[i] load luggage[i] luggage i if load>mid:
            count_track+=1
            load=luggage[i]

         load>mid load mid count_track+=1 count_track 1 load=luggage[i] load luggage[i] luggage i if count_track>count_t:
            flag=0
            break

     count_track>count_t count_track count_t flag=0 flag 0 break if flag:
        right=mid

    else:
        left=mid+1 flag right=mid right mid left=mid+1 left mid+1 mid 1 print(left) print left count_l=number[0] number[0] count_l right=mid mid right left=mid+1 mid+1 left flag=0 0 flag number=list(map(int,input().split())) list(map(int,input().split())) number flag=1 1 flag count_t=number[1] number[1] count_t max_P=sum(luggage) sum(luggage) max_P load=0 0 load mid=(left+right)//2 (left+right)//2 mid count_track+=1 1 count_track count_track=1 1 count_track min_P=max(max(luggage),sum(luggage)//count_t) max(max(luggage),sum(luggage)//count_t) min_P luggage=[int(input()) for i in range(count_l)] [int(input()) for i in range(count_l)] luggage left=min_P min_P left load+=luggage[i] luggage[i] load right=max_P max_P right load=luggage[i] luggage[i] load
number=list(map(int,input().split()))
count_l=number[0]
count_t=number[1]
luggage=[int(input()) for i in range(count_l)]

min_P=max(max(luggage),sum(luggage)//count_t)
max_P=sum(luggage)
left=min_P
right=max_P

while left<right:
    mid=(left+right)//2
    count_track=1
    flag=1
    load=0
    for i in range(count_l):
        load+=luggage[i]
        if load>mid:
            count_track+=1
            load=luggage[i]

        if count_track>count_t:
            flag=0
            break

    if flag:
        right=mid

    else:
        left=mid+1

print(left)

