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

left = 0
right = 100000*10000

while (right - left > 1):
    mid = (left + right)//2
    s = 0
    j = 1
    for i in range(n):
        if mid < w[i]:
            j = 100000
            break
        s += w[i]
        if s > mid:
            j += 1
            s = w[i]
    if j > k:
        left = mid
    else:
        right = mid
        
print(right) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input w = [int(input()) for _ in range(n)] w [int(input()) for _ in range(n)] left = 0 left 0 right = 100000*10000 right 100000*10000 100000 10000 while (right - left > 1):
    mid = (left + right)//2
    s = 0
    j = 1
    for i in range(n):
        if mid < w[i]:
            j = 100000
            break
        s += w[i]
        if s > mid:
            j += 1
            s = w[i]
    if j > k:
        left = mid
    else:
        right = mid
         right - left > 1 right - left right left 1 mid = (left + right)//2 mid (left + right)//2 left + right left right 2 s = 0 s 0 j = 1 j 1 for i in range(n):
        if mid < w[i]:
            j = 100000
            break
        s += w[i]
        if s > mid:
            j += 1
            s = w[i]
     i range(n) range n if mid < w[i]:
            j = 100000
            break
         mid < w[i] mid w[i] w i j = 100000 j 100000 break s += w[i] s w[i] w i if s > mid:
            j += 1
            s = w[i]
     s > mid s mid j += 1 j 1 s = w[i] s w[i] w i if j > k:
        left = mid
    else:
        right = mid
         j > k j k left = mid left mid right = mid right mid print(right) print right n, k = map(int, input().split()) map(int, input().split()) n j = 100000 100000 j k = map(int, input().split()) map(int, input().split()) k left = mid mid left s = w[i] w[i] s left = 0 0 left right = mid mid right j += 1 1 j right = 100000*10000 100000*10000 right mid = (left + right)//2 (left + right)//2 mid w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w s += w[i] w[i] s s = 0 0 s j = 1 1 j
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

left = 0
right = 100000*10000

while (right - left > 1):
    mid = (left + right)//2
    s = 0
    j = 1
    for i in range(n):
        if mid < w[i]:
            j = 100000
            break
        s += w[i]
        if s > mid:
            j += 1
            s = w[i]
    if j > k:
        left = mid
    else:
        right = mid
        
print(right)
