# -*- coding: utf_8 -*-

def check(t, n, k, 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

if __name__ == "__main__":
    n, k = [int (x) for x in input().split()]
    t = []
    for i in range(n):
        t.append(int(input()))

    start, end = 0, 10000 * 100000

    while (end - start > 1):
        mid = (start + end) // 2
        v = check(t, n, k, mid)
        if v >= n:
            end = mid
        else:
            start = mid

    print(end) def check(t, n, k, 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 n n return i i t t n n k k p p if __name__ == "__main__":
    n, k = [int (x) for x in input().split()]
    t = []
    for i in range(n):
        t.append(int(input()))

    start, end = 0, 10000 * 100000

    while (end - start > 1):
        mid = (start + end) // 2
        v = check(t, n, k, mid)
        if v >= n:
            end = mid
        else:
            start = mid

    print(end) __name__ == "__main__" __name__ "__main__" 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 t = [] t [] for i in range(n):
        t.append(int(input()))

     i range(n) range n t.append(int(input())) t.append t append int(input()) int input() input start, end = 0, 10000 * 100000 start 0 end 10000 * 100000 10000 100000 while (end - start > 1):
        mid = (start + end) // 2
        v = check(t, n, k, mid)
        if v >= n:
            end = mid
        else:
            start = mid

     end - start > 1 end - start end start 1 mid = (start + end) // 2 mid (start + end) // 2 start + end start end 2 v = check(t, n, k, mid) v check(t, n, k, mid) check t n k mid if v >= n:
            end = mid
        else:
            start = mid

     v >= n v n end = mid end mid start = mid start mid print(end) print end t = [] [] t start, end = 0, 10000 * 100000 0 start mid = (start + end) // 2 (start + end) // 2 mid def check(t, n, k, 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(t, n, k, 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 end = mid mid end start = mid mid start k = [int (x) for x in input().split()] [int (x) for x in input().split()] k v = check(t, n, k, mid) check(t, n, k, mid) v n, k = [int (x) for x in input().split()] [int (x) for x in input().split()] n end = 0, 10000 * 100000 10000 * 100000 end
# -*- coding: utf_8 -*-

def check(t, n, k, 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

if __name__ == "__main__":
    n, k = [int (x) for x in input().split()]
    t = []
    for i in range(n):
        t.append(int(input()))

    start, end = 0, 10000 * 100000

    while (end - start > 1):
        mid = (start + end) // 2
        v = check(t, n, k, mid)
        if v >= n:
            end = mid
        else:
            start = mid

    print(end)