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

total_weght = sum(w)

def check(p):
    track = [0 for i in range(k)]
    target = 0

    for i in range(k):
        while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
        if target not in range(n):
            break
    
    return(target)

def solve(n):
    left = 0
    right = 100000 * 100000
    while left < right:
        
        mid = (left + right) // 2
        if n == check(mid):
            right = mid
        else:
            left = mid + 1

    return(right)

if __name__ == "__main__":
    ans = solve(n)
    print(ans)
 int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n, k = (int(i) for i in input().split()) n (int(i) for i in 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)] total_weght = sum(w) total_weght sum(w) sum w def check(p):
    track = [0 for i in range(k)]
    target = 0

    for i in range(k):
        while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
        if target not in range(n):
            break
    
    return(target) check 0 for i in range(k) for i in range(k) i range(k) range k for i in range(k) 0 track = [0 for i in range(k)] track [0 for i in range(k)] target = 0 target 0 for i in range(k):
        while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
        if target not in range(n):
            break
    
     i range(k) range k while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
         (track[i] + w[target]) <= p track[i] + w[target] track[i] track i w[target] w target p track[i] += w[target] track[i] track i w[target] w target target += 1 target 1 if target not in range(n):
                break
         target not in range(n) target range(n) range n break if target not in range(n):
            break
    
     target not in range(n) target range(n) range n break return(target) target p p def solve(n):
    left = 0
    right = 100000 * 100000
    while left < right:
        
        mid = (left + right) // 2
        if n == check(mid):
            right = mid
        else:
            left = mid + 1

    return(right) solve left = 0 left 0 right = 100000 * 100000 right 100000 * 100000 100000 100000 while left < right:
        
        mid = (left + right) // 2
        if n == check(mid):
            right = mid
        else:
            left = mid + 1

     left < right left right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 if n == check(mid):
            right = mid
        else:
            left = mid + 1

     n == check(mid) n check(mid) check mid right = mid right mid left = mid + 1 left mid + 1 mid 1 return(right) right n n if __name__ == "__main__":
    ans = solve(n)
    print(ans) __name__ == "__main__" __name__ "__main__" ans = solve(n) ans solve(n) solve n print(ans) print ans w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w def solve(n):
    left = 0
    right = 100000 * 100000
    while left < right:
        
        mid = (left + right) // 2
        if n == check(mid):
            right = mid
        else:
            left = mid + 1

    return(right) def solve(n):
    left = 0
    right = 100000 * 100000
    while left < right:
        
        mid = (left + right) // 2
        if n == check(mid):
            right = mid
        else:
            left = mid + 1

    return(right) solve ans = solve(n) solve(n) ans def check(p):
    track = [0 for i in range(k)]
    target = 0

    for i in range(k):
        while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
        if target not in range(n):
            break
    
    return(target) def check(p):
    track = [0 for i in range(k)]
    target = 0

    for i in range(k):
        while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
        if target not in range(n):
            break
    
    return(target) check n, k = (int(i) for i in input().split()) (int(i) for i in input().split()) n k = (int(i) for i in input().split()) (int(i) for i in input().split()) k total_weght = sum(w) sum(w) total_weght
n, k = (int(i) for i in input().split())
w = [int(input()) for i in range(n)]

total_weght = sum(w)

def check(p):
    track = [0 for i in range(k)]
    target = 0

    for i in range(k):
        while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
        if target not in range(n):
            break
    
    return(target)

def solve(n):
    left = 0
    right = 100000 * 100000
    while left < right:
        
        mid = (left + right) // 2
        if n == check(mid):
            right = mid
        else:
            left = mid + 1

    return(right)

if __name__ == "__main__":
    ans = solve(n)
    print(ans)

