n, k = map(int, raw_input().split())
w = [int(raw_input()) for _ in xrange(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 True
    return False


def solver():
    left, right = 0, 100000 * 10000

    while left < right:
        mid = int((left + right) / 2)

        if check(mid):
            right = mid
        else:
            left = mid + 1
    
    return right


print solver() n, k = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split k int(raw_input()) for _ in xrange(n) for _ in xrange(n) _ xrange(n) xrange n for _ in xrange(n) int(raw_input()) int raw_input() raw_input w = [int(raw_input()) for _ in xrange(n)] w [int(raw_input()) for _ in xrange(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 True
    return False 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 True
     j range(k) range k s = 0 s 0 while s + w[i] <= P:
            s += w[i]
            i += 1
            if i == n:
                return True
     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 True
     i == n i n return True True return False False P P def solver():
    left, right = 0, 100000 * 10000

    while left < right:
        mid = int((left + right) / 2)

        if check(mid):
            right = mid
        else:
            left = mid + 1
    
    return right solver left, right = 0, 100000 * 10000 left 0 right 100000 * 10000 100000 10000 while left < right:
        mid = int((left + right) / 2)

        if check(mid):
            right = mid
        else:
            left = mid + 1
    
     left < right left right mid = int((left + right) / 2) mid int((left + right) / 2) int (left + right) / 2 left + right left right 2 if check(mid):
            right = mid
        else:
            left = mid + 1
    
     check(mid) check mid right = mid right mid left = mid + 1 left mid + 1 mid 1 return right right print solver() solver 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 True
    return False 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 True
    return False check n, k = map(int, raw_input().split()) map(int, raw_input().split()) n k = map(int, raw_input().split()) map(int, raw_input().split()) k w = [int(raw_input()) for _ in xrange(n)] [int(raw_input()) for _ in xrange(n)] w def solver():
    left, right = 0, 100000 * 10000

    while left < right:
        mid = int((left + right) / 2)

        if check(mid):
            right = mid
        else:
            left = mid + 1
    
    return right def solver():
    left, right = 0, 100000 * 10000

    while left < right:
        mid = int((left + right) / 2)

        if check(mid):
            right = mid
        else:
            left = mid + 1
    
    return right solver
n, k = map(int, raw_input().split())
w = [int(raw_input()) for _ in xrange(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 True
    return False


def solver():
    left, right = 0, 100000 * 10000

    while left < right:
        mid = int((left + right) / 2)

        if check(mid):
            right = mid
        else:
            left = mid + 1
    
    return right


print solver()