def is_leq_S(A, lim, K):
    S = [0] * K

    ai = 0
    si = 0

    while ai < len(A):
        if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
    return True


def main():
    N, K = [int(_) for _ in input().split()] 
    A = []
    
    for _ in range(N):
        A.append(int(input()))

    l = 0
    r = 100000 * 100000

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

        if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

    print(S)
    

main() def is_leq_S(A, lim, K):
    S = [0] * K

    ai = 0
    si = 0

    while ai < len(A):
        if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
    return True is_leq_S S = [0] * K S [0] * K [0] 0 K ai = 0 ai 0 si = 0 si 0 while ai < len(A):
        if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
     ai < len(A) ai len(A) len A if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
     S[si] + A[ai] <= lim S[si] + A[ai] S[si] S si A[ai] A ai lim S[si] += A[ai] S[si] S si A[ai] A ai ai += 1 ai 1 si += 1 si 1 if si == K:
                return False
    
     si == K si K return False False return True True A A lim lim K K def main():
    N, K = [int(_) for _ in input().split()] 
    A = []
    
    for _ in range(N):
        A.append(int(input()))

    l = 0
    r = 100000 * 100000

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

        if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

    print(S)
     main int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ N, K = [int(_) for _ in input().split()] N [int(_) for _ in input().split()] K A = [] A [] for _ in range(N):
        A.append(int(input()))

     _ range(N) range N A.append(int(input())) A.append A append int(input()) int input() input l = 0 l 0 r = 100000 * 100000 r 100000 * 100000 100000 100000 while l + 1 < r:
        m = (l + r) // 2

        if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

     l + 1 < r l + 1 l 1 r m = (l + r) // 2 m (l + r) // 2 l + r l r 2 if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

     is_leq_S(A, m, K) is_leq_S A m K S = m S m r = m r m l = m l m print(S) print S main() main def main():
    N, K = [int(_) for _ in input().split()] 
    A = []
    
    for _ in range(N):
        A.append(int(input()))

    l = 0
    r = 100000 * 100000

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

        if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

    print(S)
     def main():
    N, K = [int(_) for _ in input().split()] 
    A = []
    
    for _ in range(N):
        A.append(int(input()))

    l = 0
    r = 100000 * 100000

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

        if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

    print(S)
     main def is_leq_S(A, lim, K):
    S = [0] * K

    ai = 0
    si = 0

    while ai < len(A):
        if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
    return True def is_leq_S(A, lim, K):
    S = [0] * K

    ai = 0
    si = 0

    while ai < len(A):
        if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
    return True is_leq_S
def is_leq_S(A, lim, K):
    S = [0] * K

    ai = 0
    si = 0

    while ai < len(A):
        if S[si] + A[ai] <= lim:
            S[si] += A[ai]
            ai += 1
        else:
            si += 1

            if si == K:
                return False
    
    return True


def main():
    N, K = [int(_) for _ in input().split()] 
    A = []
    
    for _ in range(N):
        A.append(int(input()))

    l = 0
    r = 100000 * 100000

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

        if is_leq_S(A, m, K):
            S = m
            r = m
        else:
            l = m

    print(S)
    

main()
