def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
    return i

def solve():
    left, right = 0, 100000*10000
    while right - left > 1:
        mid = (left + right) / 2
        v = check(mid)
        if v >= n: right = mid
        else: left = mid
    return right

if __name__ == '__main__':
    T = []
    n, k = [int(x) for x in input().split()]
    for i in range(n): T.append(int(input()))    
    print(int(solve())) def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
    return i check i = 0 i 0 for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
     j range(k) range k s = 0 s 0 while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
     s + T[i] <= P s + T[i] s T[i] T i P s += T[i] s T[i] T i i += 1 i 1 if i == n: return n
     i == n i n return i i P P def solve():
    left, right = 0, 100000*10000
    while right - left > 1:
        mid = (left + right) / 2
        v = check(mid)
        if v >= n: right = mid
        else: left = mid
    return right solve left, right = 0, 100000*10000 left 0 right 100000*10000 100000 10000 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 return right right if __name__ == '__main__':
    T = []
    n, k = [int(x) for x in input().split()]
    for i in range(n): T.append(int(input()))    
    print(int(solve())) __name__ == '__main__' __name__ '__main__' T = [] T [] 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 for i in range(n): T.append(int(input()))    
     i range(n) range n print(int(solve())) print int(solve()) int solve() solve n, k = [int(x) for x in input().split()] [int(x) for x in input().split()] n k = [int(x) for x in input().split()] [int(x) for x in input().split()] k T = [] [] T def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
    return i def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
    return i check def solve():
    left, right = 0, 100000*10000
    while right - left > 1:
        mid = (left + right) / 2
        v = check(mid)
        if v >= n: right = mid
        else: left = mid
    return right def solve():
    left, right = 0, 100000*10000
    while right - left > 1:
        mid = (left + right) / 2
        v = check(mid)
        if v >= n: right = mid
        else: left = mid
    return right solve
def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if i == n: return n
    return i

def solve():
    left, right = 0, 100000*10000
    while right - left > 1:
        mid = (left + right) / 2
        v = check(mid)
        if v >= n: right = mid
        else: left = mid
    return right

if __name__ == '__main__':
    T = []
    n, k = [int(x) for x in input().split()]
    for i in range(n): T.append(int(input()))    
    print(int(solve()))
