def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    n, k = map(int, stdinput().split())
    W = list(map(int, [stdinput() for _ in range(n)]))

    l, r = max(W), 100000*10000

    # 二分探索で上限値を確認する
    while l != r:
        mid = (l + r) // 2
        if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

    print(l)
        
def calc_tracks(W, P):
    ret = 0
    current_w = 0
    for w in W:
        if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
    return ret + 1

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()') def stdinput():
    from sys import stdin
    return stdin.readline().strip() stdinput from sys import stdin return stdin.readline().strip() stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip def main():
    n, k = map(int, stdinput().split())
    W = list(map(int, [stdinput() for _ in range(n)]))

    l, r = max(W), 100000*10000

    # 二分探索で上限値を確認する
    while l != r:
        mid = (l + r) // 2
        if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

    print(l)
         main n, k = map(int, stdinput().split()) n map(int, stdinput().split()) map int stdinput().split() ().split () stdinput split k stdinput() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) stdinput() stdinput W = list(map(int, [stdinput() for _ in range(n)])) W list(map(int, [stdinput() for _ in range(n)])) list map(int, [stdinput() for _ in range(n)]) map int [stdinput() for _ in range(n)] l, r = max(W), 100000*10000 l max(W) max W r 100000*10000 100000 10000 while l != r:
        mid = (l + r) // 2
        if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

     l != r l r mid = (l + r) // 2 mid (l + r) // 2 l + r l r 2 if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

     calc_tracks(W, mid) <= k calc_tracks(W, mid) calc_tracks W mid k r = mid r mid l = mid + 1 l mid + 1 mid 1 print(l) print l def calc_tracks(W, P):
    ret = 0
    current_w = 0
    for w in W:
        if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
    return ret + 1 calc_tracks ret = 0 ret 0 current_w = 0 current_w 0 for w in W:
        if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
     w W if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
     current_w + w > P current_w + w current_w w P ret += 1 ret 1 current_w = w current_w w current_w += w current_w w return ret + 1 ret + 1 ret 1 W W P P if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()') __name__ == '__main__' __name__ '__main__' main() main def main():
    n, k = map(int, stdinput().split())
    W = list(map(int, [stdinput() for _ in range(n)]))

    l, r = max(W), 100000*10000

    # 二分探索で上限値を確認する
    while l != r:
        mid = (l + r) // 2
        if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

    print(l)
         def main():
    n, k = map(int, stdinput().split())
    W = list(map(int, [stdinput() for _ in range(n)]))

    l, r = max(W), 100000*10000

    # 二分探索で上限値を確認する
    while l != r:
        mid = (l + r) // 2
        if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

    print(l)
         main def calc_tracks(W, P):
    ret = 0
    current_w = 0
    for w in W:
        if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
    return ret + 1 def calc_tracks(W, P):
    ret = 0
    current_w = 0
    for w in W:
        if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
    return ret + 1 calc_tracks def stdinput():
    from sys import stdin
    return stdin.readline().strip() def stdinput():
    from sys import stdin
    return stdin.readline().strip() stdinput
def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    n, k = map(int, stdinput().split())
    W = list(map(int, [stdinput() for _ in range(n)]))

    l, r = max(W), 100000*10000

    # 二分探索で上限値を確認する
    while l != r:
        mid = (l + r) // 2
        if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

    print(l)
        
def calc_tracks(W, P):
    ret = 0
    current_w = 0
    for w in W:
        if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
    return ret + 1

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')
