import sys

n,k = map(int,sys.stdin.readline().split())
T = [int(sys.stdin.readline()) for _ in range(n)]

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

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) import sys sys n,k = map(int,sys.stdin.readline().split()) n map(int,sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split k int(sys.stdin.readline()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline T = [int(sys.stdin.readline()) for _ in range(n)] T [int(sys.stdin.readline()) for _ in range(n)] 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 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 right = mid mid right left = 0 0 left v = check(mid) check(mid) v T = [int(sys.stdin.readline()) for _ in range(n)] [int(sys.stdin.readline()) for _ in range(n)] T left = mid mid left n,k = map(int,sys.stdin.readline().split()) map(int,sys.stdin.readline().split()) n 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 k = map(int,sys.stdin.readline().split()) map(int,sys.stdin.readline().split()) k right = 100000 * 10000 100000 * 10000 right mid = (left + right)//2 (left + right)//2 mid
import sys

n,k = map(int,sys.stdin.readline().split())
T = [int(sys.stdin.readline()) for _ in range(n)]

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

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)
