n, k = map(int, input().split(' '))
w = [int(input()) for i in range(n)]

max_w = 100000 * 10000
P = 0
left = 0
right = max_w

def check(p):
    sum = 0
    count = 1
    for i in range(n):
        if(sum + w[i] > p):
            count += 1
            sum = w[i]
            if(count > k or w[i] > p):
                return False
        else:
            sum += w[i]

    return True

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

print(P) n, k = map(int, input().split(' ')) n map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' k int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input w = [int(input()) for i in range(n)] w [int(input()) for i in range(n)] max_w = 100000 * 10000 max_w 100000 * 10000 100000 10000 P = 0 P 0 left = 0 left 0 right = max_w right max_w def check(p):
    sum = 0
    count = 1
    for i in range(n):
        if(sum + w[i] > p):
            count += 1
            sum = w[i]
            if(count > k or w[i] > p):
                return False
        else:
            sum += w[i]

    return True check sum = 0 sum 0 count = 1 count 1 for i in range(n):
        if(sum + w[i] > p):
            count += 1
            sum = w[i]
            if(count > k or w[i] > p):
                return False
        else:
            sum += w[i]

     i range(n) range n if(sum + w[i] > p):
            count += 1
            sum = w[i]
            if(count > k or w[i] > p):
                return False
        else:
            sum += w[i]

     sum + w[i] > p sum + w[i] sum w[i] w i p count += 1 count 1 sum = w[i] sum w[i] w i if(count > k or w[i] > p):
                return False
         count > k or w[i] > p count > k count k w[i] > p w[i] w i p return False False sum += w[i] sum w[i] w i return True True p p while(right - left > 1):
    mid = (left + right) // 2
    if(check(mid)):
        right = mid
        P = 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 if(check(mid)):
        right = mid
        P = mid
    else:
        left = mid check(mid) check mid right = mid right mid P = mid P mid left = mid left mid print(P) print P left = mid mid left def check(p):
    sum = 0
    count = 1
    for i in range(n):
        if(sum + w[i] > p):
            count += 1
            sum = w[i]
            if(count > k or w[i] > p):
                return False
        else:
            sum += w[i]

    return True def check(p):
    sum = 0
    count = 1
    for i in range(n):
        if(sum + w[i] > p):
            count += 1
            sum = w[i]
            if(count > k or w[i] > p):
                return False
        else:
            sum += w[i]

    return True check n, k = map(int, input().split(' ')) map(int, input().split(' ')) n k = map(int, input().split(' ')) map(int, input().split(' ')) k right = max_w max_w right mid = (left + right) // 2 (left + right) // 2 mid P = mid mid P left = 0 0 left P = 0 0 P w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w max_w = 100000 * 10000 100000 * 10000 max_w right = mid mid right
n, k = map(int, input().split(' '))
w = [int(input()) for i in range(n)]

max_w = 100000 * 10000
P = 0
left = 0
right = max_w

def check(p):
    sum = 0
    count = 1
    for i in range(n):
        if(sum + w[i] > p):
            count += 1
            sum = w[i]
            if(count > k or w[i] > p):
                return False
        else:
            sum += w[i]

    return True

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

print(P)
