n, k = map(int, input().split())
#n=num of lagage
#k=num of trucks
a = []

#import sys
#input = sys.stdin.readline

a = [int(input()) for _ in range(n)]

def isOk(mx):
    num_t = 0
    t = 0
    for i in range(n):
        if a[i]>mx:
            return False
        t += a[i]
        if t>mx:
            t = a[i]
            num_t += 1
            if num_t == k:
                return False
    return True

l = sum(a)//k - 1
r = sum(a)

while l<r:
    m = (l+r)//2
    if isOk(m):
        r = m 
    else:
        m += 1
        l = m

print(m) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k a = [] a [] int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input a = [int(input()) for _ in range(n)] a [int(input()) for _ in range(n)] def isOk(mx):
    num_t = 0
    t = 0
    for i in range(n):
        if a[i]>mx:
            return False
        t += a[i]
        if t>mx:
            t = a[i]
            num_t += 1
            if num_t == k:
                return False
    return True isOk num_t = 0 num_t 0 t = 0 t 0 for i in range(n):
        if a[i]>mx:
            return False
        t += a[i]
        if t>mx:
            t = a[i]
            num_t += 1
            if num_t == k:
                return False
     i range(n) range n if a[i]>mx:
            return False
         a[i]>mx a[i] a i mx return False False t += a[i] t a[i] a i if t>mx:
            t = a[i]
            num_t += 1
            if num_t == k:
                return False
     t>mx t mx t = a[i] t a[i] a i num_t += 1 num_t 1 if num_t == k:
                return False
     num_t == k num_t k return False False return True True mx mx l = sum(a)//k - 1 l sum(a)//k - 1 sum(a)//k sum(a) sum a k 1 r = sum(a) r sum(a) sum a while l<r:
    m = (l+r)//2
    if isOk(m):
        r = m 
    else:
        m += 1
        l = m l<r l r m = (l+r)//2 m (l+r)//2 l+r l r 2 if isOk(m):
        r = m 
    else:
        m += 1
        l = m isOk(m) isOk m r = m r m m += 1 m 1 l = m l m print(m) print m l = sum(a)//k - 1 sum(a)//k - 1 l m += 1 1 m def isOk(mx):
    num_t = 0
    t = 0
    for i in range(n):
        if a[i]>mx:
            return False
        t += a[i]
        if t>mx:
            t = a[i]
            num_t += 1
            if num_t == k:
                return False
    return True def isOk(mx):
    num_t = 0
    t = 0
    for i in range(n):
        if a[i]>mx:
            return False
        t += a[i]
        if t>mx:
            t = a[i]
            num_t += 1
            if num_t == k:
                return False
    return True isOk n, k = map(int, input().split()) map(int, input().split()) n m = (l+r)//2 (l+r)//2 m l = m m l a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a k = map(int, input().split()) map(int, input().split()) k r = sum(a) sum(a) r r = m m r a = [] [] a
n, k = map(int, input().split())
#n=num of lagage
#k=num of trucks
a = []

#import sys
#input = sys.stdin.readline

a = [int(input()) for _ in range(n)]

def isOk(mx):
    num_t = 0
    t = 0
    for i in range(n):
        if a[i]>mx:
            return False
        t += a[i]
        if t>mx:
            t = a[i]
            num_t += 1
            if num_t == k:
                return False
    return True

l = sum(a)//k - 1
r = sum(a)

while l<r:
    m = (l+r)//2
    if isOk(m):
        r = m 
    else:
        m += 1
        l = m

print(m)
