# -*- coding: utf-8 -*-


if __name__ == '__main__':

    n, k = [int(s) for s in input().split(" ")]
    W = [int(input()) for _ in range(n)]

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

        return i

    left = 0
    right = 100000 * 10000

    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    print(right)  
 if __name__ == '__main__':

    n, k = [int(s) for s in input().split(" ")]
    W = [int(input()) for _ in range(n)]

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

        return i

    left = 0
    right = 100000 * 10000

    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    print(right)   __name__ == '__main__' __name__ '__main__' int(s) for s in input().split(" ") for s in input().split(" ") s input().split(" ") ().split () input split " " for s in input().split(" ") int(s) int s n, k = [int(s) for s in input().split(" ")] n [int(s) for s 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)] def check(P):
        i = 0
        for j in range(k):
            s = 0
            while (s + W[i]) <= P:
                s += W[i]
                i += 1
                if i==n:
                    return n

        return i

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

         j range(k) range k s = 0 s 0 while (s + W[i]) <= P:
                s += W[i]
                i += 1
                if i==n:
                    return n

         (s + W[i]) <= P s + W[i] s W[i] W i P s += W[i] s W[i] W i i += 1 i 1 if i==n:
                    return n

         i==n i n return n n return i i P P left = 0 left 0 right = 100000 * 10000 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 right = mid right mid left = mid left mid print(right) print right def check(P):
        i = 0
        for j in range(k):
            s = 0
            while (s + W[i]) <= P:
                s += W[i]
                i += 1
                if i==n:
                    return n

        return i

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

        return i

     check k = [int(s) for s in input().split(" ")] [int(s) for s in input().split(" ")] k left = 0 0 left v = check(mid) check(mid) v W = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] W left = mid mid left right = 100000 * 10000 100000 * 10000 right right = mid mid right n, k = [int(s) for s in input().split(" ")] [int(s) for s in input().split(" ")] n mid = (left + right) // 2 (left + right) // 2 mid
# -*- coding: utf-8 -*-


if __name__ == '__main__':

    n, k = [int(s) for s in input().split(" ")]
    W = [int(input()) for _ in range(n)]

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

        return i

    left = 0
    right = 100000 * 10000

    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    print(right)  

