num, count = map(int, input().split())
baggages = [int(input()) for _ in range(num)]

def check(capacity):
    index = 0
    for _ in range(count):
        weight = 0
        while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
    return index


L,R = 0, 100000*10000
while R - L > 1:
    pivot = (L + R) // 2
    v = check(pivot)
    if v >= num:
        R = pivot
    else:
        L = pivot
print(R) num, count = map(int, input().split()) num map(int, input().split()) map int input().split() ().split () input split count int(input()) for _ in range(num) for _ in range(num) _ range(num) range num for _ in range(num) int(input()) int input() input baggages = [int(input()) for _ in range(num)] baggages [int(input()) for _ in range(num)] def check(capacity):
    index = 0
    for _ in range(count):
        weight = 0
        while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
    return index check index = 0 index 0 for _ in range(count):
        weight = 0
        while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
     _ range(count) range count weight = 0 weight 0 while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
     weight + baggages[index] <= capacity weight + baggages[index] weight baggages[index] baggages index capacity weight += baggages[index] weight baggages[index] baggages index index  += 1 index 1 if index == num:
                return num
     index == num index num return num num return index index capacity capacity L,R = 0, 100000*10000 L 0 R 100000*10000 100000 10000 while R - L > 1:
    pivot = (L + R) // 2
    v = check(pivot)
    if v >= num:
        R = pivot
    else:
        L = pivot R - L > 1 R - L R L 1 pivot = (L + R) // 2 pivot (L + R) // 2 L + R L R 2 v = check(pivot) v check(pivot) check pivot if v >= num:
        R = pivot
    else:
        L = pivot v >= num v num R = pivot R pivot L = pivot L pivot print(R) print R L = pivot pivot L count = map(int, input().split()) map(int, input().split()) count R = pivot pivot R num, count = map(int, input().split()) map(int, input().split()) num baggages = [int(input()) for _ in range(num)] [int(input()) for _ in range(num)] baggages v = check(pivot) check(pivot) v def check(capacity):
    index = 0
    for _ in range(count):
        weight = 0
        while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
    return index def check(capacity):
    index = 0
    for _ in range(count):
        weight = 0
        while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
    return index check R = 0, 100000*10000 100000*10000 R L,R = 0, 100000*10000 0 L pivot = (L + R) // 2 (L + R) // 2 pivot
num, count = map(int, input().split())
baggages = [int(input()) for _ in range(num)]

def check(capacity):
    index = 0
    for _ in range(count):
        weight = 0
        while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
    return index


L,R = 0, 100000*10000
while R - L > 1:
    pivot = (L + R) // 2
    v = check(pivot)
    if v >= num:
        R = pivot
    else:
        L = pivot
print(R)
