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

def check(p):
    i = 0
    for _ in range(k):
        wight = 0
        while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
    return i

if __name__ == '__main__':
    left = 0
    right = 100000 * 10000
    mid = 0
    while right - left > 1:
        mid = (left+right)//2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    print(right)
 n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k w = [] w [] for i in range(n):
    w.append(int(input())) i range(n) range n w.append(int(input())) w.append w append int(input()) int input() input def check(p):
    i = 0
    for _ in range(k):
        wight = 0
        while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
    return i check i = 0 i 0 for _ in range(k):
        wight = 0
        while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
     _ range(k) range k wight = 0 wight 0 while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
     wight+w[i] <= p wight+w[i] wight w[i] w i p wight += w[i] wight w[i] w i i += 1 i 1 if i == n:
                return n
     i == n i n return n n return i i p p if __name__ == '__main__':
    left = 0
    right = 100000 * 10000
    mid = 0
    while right - left > 1:
        mid = (left+right)//2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    print(right) __name__ == '__main__' __name__ '__main__' left = 0 left 0 right = 100000 * 10000 right 100000 * 10000 100000 10000 mid = 0 mid 0 while right - left > 1:
        mid = (left+right)//2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
     right - left > 1 right - left right left 1 mid = (left+right)//2 mid (left+right)//2 left+right left right 2 v = check(mid) v check(mid) check mid if v >= n:
            right = mid
        else:
            left = mid
     v >= n v n right = mid right mid left = mid left mid print(right) print right def check(p):
    i = 0
    for _ in range(k):
        wight = 0
        while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
    return i def check(p):
    i = 0
    for _ in range(k):
        wight = 0
        while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
    return i check mid = (left+right)//2 (left+right)//2 mid right = 100000 * 10000 100000 * 10000 right right = mid mid right left = mid mid left k = map(int, input().split()) map(int, input().split()) k v = check(mid) check(mid) v left = 0 0 left mid = 0 0 mid w = [] [] w n, k = map(int, input().split()) map(int, input().split()) n
n, k = map(int, input().split())
w = []
for i in range(n):
    w.append(int(input()))

def check(p):
    i = 0
    for _ in range(k):
        wight = 0
        while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
    return i

if __name__ == '__main__':
    left = 0
    right = 100000 * 10000
    mid = 0
    while right - left > 1:
        mid = (left+right)//2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    print(right)

