def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage

def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = 10000 * baggage_num
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right


import sys

n, k = map(int, sys.stdin.readline().split())

T = list(map(int, sys.stdin))

P = min_capacity(T, n, k)

print(P) def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage carriable_baggage """Return the number of baggae which trucks can carry.""" laden_baggage = 0 laden_baggage 0 for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
     i range(truck_num) range truck_num laden_weight = 0 laden_weight 0 while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
     laden_weight + baggage[laden_baggage] <= truck_capacity laden_weight + baggage[laden_baggage] laden_weight baggage[laden_baggage] baggage laden_baggage truck_capacity laden_weight += baggage[laden_baggage] laden_weight baggage[laden_baggage] baggage laden_baggage laden_baggage += 1 laden_baggage 1 if laden_baggage == baggage_num:
                return baggage_num
     laden_baggage == baggage_num laden_baggage baggage_num return baggage_num baggage_num return laden_baggage laden_baggage baggage baggage baggage_num baggage_num truck_capacity truck_capacity truck_num truck_num def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = 10000 * baggage_num
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right min_capacity """Return the minimum value of maximum load capacity of trucks.""" left = 0 left 0 right = 10000 * baggage_num right 10000 * baggage_num 10000 baggage_num while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            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 = carriable_baggage(baggage, baggage_num, mid, truck_num) v carriable_baggage(baggage, baggage_num, mid, truck_num) carriable_baggage baggage baggage_num mid truck_num if v >= baggage_num:
            right = mid;
        else:
            left = mid
     v >= baggage_num v baggage_num right = mid right mid left = mid left mid return right right baggage baggage baggage_num baggage_num truck_num truck_num 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 T = list(map(int, sys.stdin)) T list(map(int, sys.stdin)) list map(int, sys.stdin) map int sys.stdin sys stdin P = min_capacity(T, n, k) P min_capacity(T, n, k) min_capacity T n k print(P) print P n, k = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n k = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) k def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = 10000 * baggage_num
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = 10000 * baggage_num
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right min_capacity P = min_capacity(T, n, k) min_capacity(T, n, k) P T = list(map(int, sys.stdin)) list(map(int, sys.stdin)) T def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage carriable_baggage
def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage

def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = 10000 * baggage_num
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right


import sys

n, k = map(int, sys.stdin.readline().split())

T = list(map(int, sys.stdin))

P = min_capacity(T, n, k)

print(P)