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

P = 10 ** 4 * 10 ** 5

mi = 0
ma = P

while ma - mi > 1:
    ans = (ma + mi) // 2
    now = 0
    count = 1
    is_success = True
    for v in w:
        if now + v <= ans:
            now += v
        else:
            now = v
            count += 1
            if count > k or now > ans:
                mi = ans
                is_success = False
                break
    if is_success:
        ma = ans

print(ma)


 int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n, k = [int(x) for x in input().split()] n [int(x) for x in 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)] P = 10 ** 4 * 10 ** 5 P 10 ** 4 * 10 ** 5 10 ** 4 10 4 10 ** 5 10 5 mi = 0 mi 0 ma = P ma P while ma - mi > 1:
    ans = (ma + mi) // 2
    now = 0
    count = 1
    is_success = True
    for v in w:
        if now + v <= ans:
            now += v
        else:
            now = v
            count += 1
            if count > k or now > ans:
                mi = ans
                is_success = False
                break
    if is_success:
        ma = ans ma - mi > 1 ma - mi ma mi 1 ans = (ma + mi) // 2 ans (ma + mi) // 2 ma + mi ma mi 2 now = 0 now 0 count = 1 count 1 is_success = True is_success True for v in w:
        if now + v <= ans:
            now += v
        else:
            now = v
            count += 1
            if count > k or now > ans:
                mi = ans
                is_success = False
                break
     v w if now + v <= ans:
            now += v
        else:
            now = v
            count += 1
            if count > k or now > ans:
                mi = ans
                is_success = False
                break
     now + v <= ans now + v now v ans now += v now v now = v now v count += 1 count 1 if count > k or now > ans:
                mi = ans
                is_success = False
                break
     count > k or now > ans count > k count k now > ans now ans mi = ans mi ans is_success = False is_success False break if is_success:
        ma = ans is_success ma = ans ma ans print(ma) print ma ans = (ma + mi) // 2 (ma + mi) // 2 ans n, k = [int(x) for x in input().split()] [int(x) for x in input().split()] n count = 1 1 count w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w P = 10 ** 4 * 10 ** 5 10 ** 4 * 10 ** 5 P ma = ans ans ma count += 1 1 count now = 0 0 now k = [int(x) for x in input().split()] [int(x) for x in input().split()] k mi = 0 0 mi mi = ans ans mi is_success = True True is_success now += v v now ma = P P ma now = v v now is_success = False False is_success
n, k = [int(x) for x in input().split()]
w = [int(input()) for _ in range(n)]

P = 10 ** 4 * 10 ** 5

mi = 0
ma = P

while ma - mi > 1:
    ans = (ma + mi) // 2
    now = 0
    count = 1
    is_success = True
    for v in w:
        if now + v <= ans:
            now += v
        else:
            now = v
            count += 1
            if count > k or now > ans:
                mi = ans
                is_success = False
                break
    if is_success:
        ma = ans

print(ma)



