n,k = map(int,input().split())
w = []

for loop in range(n):
    w.append(int(input()))

left = max(w)
right = 100000 * 10000
mid = (left+right)//2
ans = right

def check(P):
    tmp_sum = 0
    cnt = 1
    for loop in range(n):
        if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
    return True

while left <= right:
    if check(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1
    mid = (left+right)//2

print(ans) n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k w = [] w [] for loop in range(n):
    w.append(int(input())) loop range(n) range n w.append(int(input())) w.append w append int(input()) int input() input left = max(w) left max(w) max w right = 100000 * 10000 right 100000 * 10000 100000 10000 mid = (left+right)//2 mid (left+right)//2 left+right left right 2 ans = right ans right def check(P):
    tmp_sum = 0
    cnt = 1
    for loop in range(n):
        if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
    return True check tmp_sum = 0 tmp_sum 0 cnt = 1 cnt 1 for loop in range(n):
        if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
     loop range(n) range n if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
     tmp_sum + w[loop] <= P tmp_sum + w[loop] tmp_sum w[loop] w loop P tmp_sum += w[loop] tmp_sum w[loop] w loop tmp_sum = w[loop] tmp_sum w[loop] w loop cnt += 1 cnt 1 if cnt > k:
                return False
     cnt > k cnt k return False False return True True P P while left <= right:
    if check(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1
    mid = (left+right)//2 left <= right left right if check(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1
     check(mid) check mid ans = mid ans mid right = mid - 1 right mid - 1 mid 1 left = mid + 1 left mid + 1 mid 1 mid = (left+right)//2 mid (left+right)//2 left+right left right 2 print(ans) print ans mid = (left+right)//2 (left+right)//2 mid def check(P):
    tmp_sum = 0
    cnt = 1
    for loop in range(n):
        if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
    return True def check(P):
    tmp_sum = 0
    cnt = 1
    for loop in range(n):
        if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
    return True check mid = (left+right)//2 (left+right)//2 mid left = max(w) max(w) left right = mid - 1 mid - 1 right n,k = map(int,input().split()) map(int,input().split()) n k = map(int,input().split()) map(int,input().split()) k left = mid + 1 mid + 1 left w = [] [] w ans = mid mid ans right = 100000 * 10000 100000 * 10000 right ans = right right ans
n,k = map(int,input().split())
w = []

for loop in range(n):
    w.append(int(input()))

left = max(w)
right = 100000 * 10000
mid = (left+right)//2
ans = right

def check(P):
    tmp_sum = 0
    cnt = 1
    for loop in range(n):
        if tmp_sum + w[loop] <= P:
            tmp_sum += w[loop]
        else:
            tmp_sum = w[loop]
            cnt += 1
            if cnt > k:
                return False
    return True

while left <= right:
    if check(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1
    mid = (left+right)//2

print(ans)
