n, k = map(int, raw_input().split())
W = [input() for _ in xrange(n)]

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

def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = int((right + left) / 2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    return right

def main():
    ans = solve()
    print ans
    return 0

main() n, k = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split k input() for _ in xrange(n) for _ in xrange(n) _ xrange(n) xrange n for _ in xrange(n) input() input W = [input() for _ in xrange(n)] W [input() for _ in xrange(n)] def check(p):
    i = 0
    for j in xrange(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 xrange(k):
        s = 0
        while s + W[i] <= p:
            s += W[i]
            i += 1
            if (i == n):
                return n
     j xrange(k) xrange 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 def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = int((right + left) / 2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    return right solve left = 0 left 0 right = 100000 * 10000 right 100000 * 10000 100000 10000 while right - left > 1:
        mid = int((right + left) / 2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

     right - left > 1 right - left right left 1 mid = int((right + left) / 2) mid int((right + left) / 2) int (right + left) / 2 right + left right left 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 return right right def main():
    ans = solve()
    print ans
    return 0 main ans = solve() ans solve() solve print return 0 0 main() main def check(p):
    i = 0
    for j in xrange(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 xrange(k):
        s = 0
        while s + W[i] <= p:
            s += W[i]
            i += 1
            if (i == n):
                return n
    return i check W = [input() for _ in xrange(n)] [input() for _ in xrange(n)] W def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = int((right + left) / 2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    return right def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = int((right + left) / 2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    return right solve k = map(int, raw_input().split()) map(int, raw_input().split()) k n, k = map(int, raw_input().split()) map(int, raw_input().split()) n def main():
    ans = solve()
    print ans
    return 0 def main():
    ans = solve()
    print ans
    return 0 main
n, k = map(int, raw_input().split())
W = [input() for _ in xrange(n)]

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

def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = int((right + left) / 2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    return right

def main():
    ans = solve()
    print ans
    return 0

main()