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

def solve():
    left   = 0
    right  = 10**5 * 10**4
    middle = 0
    while(right-left > 1):
        middle = (left+right)//2
        v = check(middle)
        if(v >= len(n_list)):
            right = middle
        else:
            left = middle
    return right

n,k = map(int,input().split())
n_list = [int(input()) for _ in range(n)]
ans = solve()
print(ans) def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s+n_list[i] <= p:
            s += n_list[i]
            i += 1
            if i == n:
                return n
    return i check i = 0 i 0 for _ in range(k):
        s = 0
        while s+n_list[i] <= p:
            s += n_list[i]
            i += 1
            if i == n:
                return n
     _ range(k) range k s = 0 s 0 while s+n_list[i] <= p:
            s += n_list[i]
            i += 1
            if i == n:
                return n
     s+n_list[i] <= p s+n_list[i] s n_list[i] n_list i p s += n_list[i] s n_list[i] n_list i i += 1 i 1 if i == n:
                return n
     i == n i n return n n return i i p p def solve():
    left   = 0
    right  = 10**5 * 10**4
    middle = 0
    while(right-left > 1):
        middle = (left+right)//2
        v = check(middle)
        if(v >= len(n_list)):
            right = middle
        else:
            left = middle
    return right solve left   = 0 left 0 right  = 10**5 * 10**4 right 10**5 * 10**4 10**5 10 5 10**4 10 4 middle = 0 middle 0 while(right-left > 1):
        middle = (left+right)//2
        v = check(middle)
        if(v >= len(n_list)):
            right = middle
        else:
            left = middle
     right-left > 1 right-left right left 1 middle = (left+right)//2 middle (left+right)//2 left+right left right 2 v = check(middle) v check(middle) check middle if(v >= len(n_list)):
            right = middle
        else:
            left = middle
     v >= len(n_list) v len(n_list) len n_list right = middle right middle left = middle left middle return right 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 n_list = [int(input()) for _ in range(n)] n_list [int(input()) for _ in range(n)] ans = solve() ans solve() solve print(ans) print ans ans = solve() solve() ans def solve():
    left   = 0
    right  = 10**5 * 10**4
    middle = 0
    while(right-left > 1):
        middle = (left+right)//2
        v = check(middle)
        if(v >= len(n_list)):
            right = middle
        else:
            left = middle
    return right def solve():
    left   = 0
    right  = 10**5 * 10**4
    middle = 0
    while(right-left > 1):
        middle = (left+right)//2
        v = check(middle)
        if(v >= len(n_list)):
            right = middle
        else:
            left = middle
    return right solve k = map(int,input().split()) map(int,input().split()) k n_list = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] n_list n,k = map(int,input().split()) map(int,input().split()) n def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s+n_list[i] <= p:
            s += n_list[i]
            i += 1
            if i == n:
                return n
    return i def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s+n_list[i] <= p:
            s += n_list[i]
            i += 1
            if i == n:
                return n
    return i check
def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s+n_list[i] <= p:
            s += n_list[i]
            i += 1
            if i == n:
                return n
    return i

def solve():
    left   = 0
    right  = 10**5 * 10**4
    middle = 0
    while(right-left > 1):
        middle = (left+right)//2
        v = check(middle)
        if(v >= len(n_list)):
            right = middle
        else:
            left = middle
    return right

n,k = map(int,input().split())
n_list = [int(input()) for _ in range(n)]
ans = solve()
print(ans)
