n,k = map(int,input().split())
w = []
for _ in range(n):
    w.append(int(input()))

def enough(p,k,w):
    count = 0
    in_truck = 0
    for x in w:
        if x > p:
            return False
        else:
            if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
    if in_truck > 0:
        count += 1
    return k >= count

maximum = sum(w)
minimum = 1

while True:
    if minimum == maximum:
        break
    else:
        tmpp = (maximum + minimum) // 2
        if enough(tmpp,k,w):
            maximum = tmpp
        else:
            minimum = tmpp + 1

print(minimum) n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k w = [] w [] for _ in range(n):
    w.append(int(input())) _ range(n) range n w.append(int(input())) w.append w append int(input()) int input() input def enough(p,k,w):
    count = 0
    in_truck = 0
    for x in w:
        if x > p:
            return False
        else:
            if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
    if in_truck > 0:
        count += 1
    return k >= count enough count = 0 count 0 in_truck = 0 in_truck 0 for x in w:
        if x > p:
            return False
        else:
            if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
     x w if x > p:
            return False
        else:
            if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
     x > p x p return False False if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
     in_truck + x > p in_truck + x in_truck x p count += 1 count 1 in_truck = x in_truck x in_truck += x in_truck x if in_truck > 0:
        count += 1
     in_truck > 0 in_truck 0 count += 1 count 1 return k >= count k >= count k count p p k k w w maximum = sum(w) maximum sum(w) sum w minimum = 1 minimum 1 while True:
    if minimum == maximum:
        break
    else:
        tmpp = (maximum + minimum) // 2
        if enough(tmpp,k,w):
            maximum = tmpp
        else:
            minimum = tmpp + 1 True if minimum == maximum:
        break
    else:
        tmpp = (maximum + minimum) // 2
        if enough(tmpp,k,w):
            maximum = tmpp
        else:
            minimum = tmpp + 1 minimum == maximum minimum maximum break tmpp = (maximum + minimum) // 2 tmpp (maximum + minimum) // 2 maximum + minimum maximum minimum 2 if enough(tmpp,k,w):
            maximum = tmpp
        else:
            minimum = tmpp + 1 enough(tmpp,k,w) enough tmpp k w maximum = tmpp maximum tmpp minimum = tmpp + 1 minimum tmpp + 1 tmpp 1 print(minimum) print minimum maximum = tmpp tmpp maximum tmpp = (maximum + minimum) // 2 (maximum + minimum) // 2 tmpp def enough(p,k,w):
    count = 0
    in_truck = 0
    for x in w:
        if x > p:
            return False
        else:
            if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
    if in_truck > 0:
        count += 1
    return k >= count def enough(p,k,w):
    count = 0
    in_truck = 0
    for x in w:
        if x > p:
            return False
        else:
            if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
    if in_truck > 0:
        count += 1
    return k >= count enough maximum = sum(w) sum(w) maximum minimum = 1 1 minimum n,k = map(int,input().split()) map(int,input().split()) n k = map(int,input().split()) map(int,input().split()) k minimum = tmpp + 1 tmpp + 1 minimum w = [] [] w
n,k = map(int,input().split())
w = []
for _ in range(n):
    w.append(int(input()))

def enough(p,k,w):
    count = 0
    in_truck = 0
    for x in w:
        if x > p:
            return False
        else:
            if in_truck + x > p:
                count += 1
                in_truck = x
            else:
                in_truck += x
    if in_truck > 0:
        count += 1
    return k >= count

maximum = sum(w)
minimum = 1

while True:
    if minimum == maximum:
        break
    else:
        tmpp = (maximum + minimum) // 2
        if enough(tmpp,k,w):
            maximum = tmpp
        else:
            minimum = tmpp + 1

print(minimum)
