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

def check(x):
    cnt, tmp = 0, 0
    for i in range(n):
        if x < arr[i]:
            return False
        elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
        else:
            tmp += arr[i]
        if i == n - 1 and tmp > 0:
            cnt += 1
    return cnt <= k

l, r = 1, int(1e9 + 1)
while l < r:
    mid = (l + r) >> 1
    if check(mid):
        r = mid
    else:
        l = mid + 1
print(l) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k arr = [] arr [] for _ in range(n):
    arr.append(int(input())) _ range(n) range n arr.append(int(input())) arr.append arr append int(input()) int input() input def check(x):
    cnt, tmp = 0, 0
    for i in range(n):
        if x < arr[i]:
            return False
        elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
        else:
            tmp += arr[i]
        if i == n - 1 and tmp > 0:
            cnt += 1
    return cnt <= k check cnt, tmp = 0, 0 cnt 0 tmp 0 for i in range(n):
        if x < arr[i]:
            return False
        elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
        else:
            tmp += arr[i]
        if i == n - 1 and tmp > 0:
            cnt += 1
     i range(n) range n if x < arr[i]:
            return False
        elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
        else:
            tmp += arr[i]
         x < arr[i] x arr[i] arr i return False False elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
         tmp + arr[i] > x tmp + arr[i] tmp arr[i] arr i x tmp = arr[i] tmp arr[i] arr i cnt += 1 cnt 1 tmp += arr[i] tmp arr[i] arr i if i == n - 1 and tmp > 0:
            cnt += 1
     i == n - 1 and tmp > 0 i == n - 1 i n - 1 n 1 tmp > 0 tmp 0 cnt += 1 cnt 1 return cnt <= k cnt <= k cnt k x x l, r = 1, int(1e9 + 1) l 1 r int(1e9 + 1) int 1e9 + 1 1e9 1 while l < r:
    mid = (l + r) >> 1
    if check(mid):
        r = mid
    else:
        l = mid + 1 l < r l r mid = (l + r) >> 1 mid (l + r) >> 1 l + r l r 1 if check(mid):
        r = mid
    else:
        l = mid + 1 check(mid) check mid r = mid r mid l = mid + 1 l mid + 1 mid 1 print(l) print l r = mid mid r mid = (l + r) >> 1 (l + r) >> 1 mid l = mid + 1 mid + 1 l k = map(int, input().split()) map(int, input().split()) k def check(x):
    cnt, tmp = 0, 0
    for i in range(n):
        if x < arr[i]:
            return False
        elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
        else:
            tmp += arr[i]
        if i == n - 1 and tmp > 0:
            cnt += 1
    return cnt <= k def check(x):
    cnt, tmp = 0, 0
    for i in range(n):
        if x < arr[i]:
            return False
        elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
        else:
            tmp += arr[i]
        if i == n - 1 and tmp > 0:
            cnt += 1
    return cnt <= k check r = 1, int(1e9 + 1) int(1e9 + 1) r arr = [] [] arr n, k = map(int, input().split()) map(int, input().split()) n l, r = 1, int(1e9 + 1) 1 l
n, k = map(int, input().split())
arr = []
for _ in range(n):
    arr.append(int(input()))

def check(x):
    cnt, tmp = 0, 0
    for i in range(n):
        if x < arr[i]:
            return False
        elif tmp + arr[i] > x:
            tmp = arr[i]
            cnt += 1
        else:
            tmp += arr[i]
        if i == n - 1 and tmp > 0:
            cnt += 1
    return cnt <= k

l, r = 1, int(1e9 + 1)
while l < r:
    mid = (l + r) >> 1
    if check(mid):
        r = mid
    else:
        l = mid + 1
print(l)
