W_MAX = 10000
K_MAX = 100000


def main():
    n, k = map(int, input().split(' '))
    ws = [int(input()) for _ in range(n)]
    start = 1
    end = n*K_MAX
    target = int((start + end) / 2)
    while end > start:
        if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
        target = int((start + end) / 2)
    print(target)


def number(p, ws):
    _p = p
    num_track = 1
    for w in ws:
        if w > p:
            return K_MAX+1
        if w > _p:
            _p = p
            num_track += 1
        if w <= _p:
            _p -= w
    return num_track


if __name__ == '__main__':
    main()
 W_MAX = 10000 W_MAX 10000 K_MAX = 100000 K_MAX 100000 def main():
    n, k = map(int, input().split(' '))
    ws = [int(input()) for _ in range(n)]
    start = 1
    end = n*K_MAX
    target = int((start + end) / 2)
    while end > start:
        if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
        target = int((start + end) / 2)
    print(target) main n, k = map(int, input().split(' ')) n map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input ws = [int(input()) for _ in range(n)] ws [int(input()) for _ in range(n)] start = 1 start 1 end = n*K_MAX end n*K_MAX n K_MAX target = int((start + end) / 2) target int((start + end) / 2) int (start + end) / 2 start + end start end 2 while end > start:
        if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
        target = int((start + end) / 2)
     end > start end start if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
         number(target, ws) <= k number(target, ws) number target ws k end = target end target elif number(target, ws) > k:
            start = target + 1
         number(target, ws) > k number(target, ws) number target ws k start = target + 1 start target + 1 target 1 target = int((start + end) / 2) target int((start + end) / 2) int (start + end) / 2 start + end start end 2 print(target) print target def number(p, ws):
    _p = p
    num_track = 1
    for w in ws:
        if w > p:
            return K_MAX+1
        if w > _p:
            _p = p
            num_track += 1
        if w <= _p:
            _p -= w
    return num_track number _p = p _p p num_track = 1 num_track 1 for w in ws:
        if w > p:
            return K_MAX+1
        if w > _p:
            _p = p
            num_track += 1
        if w <= _p:
            _p -= w
     w ws if w > p:
            return K_MAX+1
         w > p w p return K_MAX+1 K_MAX+1 K_MAX 1 if w > _p:
            _p = p
            num_track += 1
         w > _p w _p _p = p _p p num_track += 1 num_track 1 if w <= _p:
            _p -= w
     w <= _p w _p _p -= w _p w return num_track num_track p p ws ws if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main W_MAX = 10000 10000 W_MAX def main():
    n, k = map(int, input().split(' '))
    ws = [int(input()) for _ in range(n)]
    start = 1
    end = n*K_MAX
    target = int((start + end) / 2)
    while end > start:
        if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
        target = int((start + end) / 2)
    print(target) def main():
    n, k = map(int, input().split(' '))
    ws = [int(input()) for _ in range(n)]
    start = 1
    end = n*K_MAX
    target = int((start + end) / 2)
    while end > start:
        if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
        target = int((start + end) / 2)
    print(target) main K_MAX = 100000 100000 K_MAX def number(p, ws):
    _p = p
    num_track = 1
    for w in ws:
        if w > p:
            return K_MAX+1
        if w > _p:
            _p = p
            num_track += 1
        if w <= _p:
            _p -= w
    return num_track def number(p, ws):
    _p = p
    num_track = 1
    for w in ws:
        if w > p:
            return K_MAX+1
        if w > _p:
            _p = p
            num_track += 1
        if w <= _p:
            _p -= w
    return num_track number
W_MAX = 10000
K_MAX = 100000


def main():
    n, k = map(int, input().split(' '))
    ws = [int(input()) for _ in range(n)]
    start = 1
    end = n*K_MAX
    target = int((start + end) / 2)
    while end > start:
        if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
        target = int((start + end) / 2)
    print(target)


def number(p, ws):
    _p = p
    num_track = 1
    for w in ws:
        if w > p:
            return K_MAX+1
        if w > _p:
            _p = p
            num_track += 1
        if w <= _p:
            _p -= w
    return num_track


if __name__ == '__main__':
    main()

