if __name__ == '__main__':
    n, k = map(int, input().split())
    total = 0
    data = []
    
    for i in range(n):
        data.append(int(input()))
        total += data[i]

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

    def solve():
        left = 0
        right = total + 1
        
        while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
        return right

    print(solve())
 if __name__ == '__main__':
    n, k = map(int, input().split())
    total = 0
    data = []
    
    for i in range(n):
        data.append(int(input()))
        total += data[i]

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

    def solve():
        left = 0
        right = total + 1
        
        while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
        return right

    print(solve()) __name__ == '__main__' __name__ '__main__' n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k total = 0 total 0 data = [] data [] for i in range(n):
        data.append(int(input()))
        total += data[i]

     i range(n) range n data.append(int(input())) data.append data append int(input()) int input() input total += data[i] total data[i] data i def check(weight):
        i = 0
        for j in range(k):
            s = 0
            while s + data[i] <= weight:
                s += data[i]
                i += 1
                if i == n:
                    return n
        return i

     check i = 0 i 0 for j in range(k):
            s = 0
            while s + data[i] <= weight:
                s += data[i]
                i += 1
                if i == n:
                    return n
         j range(k) range k s = 0 s 0 while s + data[i] <= weight:
                s += data[i]
                i += 1
                if i == n:
                    return n
         s + data[i] <= weight s + data[i] s data[i] data i weight s += data[i] s data[i] data i i += 1 i 1 if i == n:
                    return n
         i == n i n return n n return i i weight weight def solve():
        left = 0
        right = total + 1
        
        while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
        return right

     solve left = 0 left 0 right = total + 1 right total + 1 total 1 while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
         right > left right left mid = (right + left)//2 mid (right + left)//2 right + left right left 2 c = check(mid) c check(mid) check mid if c >= n:
                right = mid
            else:
                left = mid + 1
         c >= n c n right = mid right mid left = mid + 1 left mid + 1 mid 1 return right right print(solve()) print solve() solve total = 0 0 total def check(weight):
        i = 0
        for j in range(k):
            s = 0
            while s + data[i] <= weight:
                s += data[i]
                i += 1
                if i == n:
                    return n
        return i

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

     check def solve():
        left = 0
        right = total + 1
        
        while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
        return right

     def solve():
        left = 0
        right = total + 1
        
        while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
        return right

     solve data = [] [] data k = map(int, input().split()) map(int, input().split()) k total += data[i] data[i] total n, k = map(int, input().split()) map(int, input().split()) n
if __name__ == '__main__':
    n, k = map(int, input().split())
    total = 0
    data = []
    
    for i in range(n):
        data.append(int(input()))
        total += data[i]

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

    def solve():
        left = 0
        right = total + 1
        
        while right > left:
            mid = (right + left)//2
            c = check(mid) # 检查当每辆车的装载量为 mid 时，最多能装多少件货物
            if c >= n:
                right = mid
            else:
                left = mid + 1
        return right

    print(solve())

