from sys import stdin
import sys
import math
n,k=list(map(int,(stdin.readline().strip().split())))
w=[int(input()) for x in range(n)]
def f(p):
    i=0
    for j in range(k):
        weight=0
        while(weight+w[i]<=p):
            weight+=w[i]
            i+=1
            if i==n:return n
    return i
left=0
right=10**9+1
mid=right//2
while(True):
    length=f(mid)
    if length==n:
        l=f(mid-1)
        if length==l:
            right=mid
            mid=(right+left)//2
        else:
            print(mid)
            exit()
    if length>n:
        right=mid
        mid=(right+left)//2
    if length<n:
        left=mid
        mid=(right+left)//2 from sys import stdin import sys sys import math math n,k=list(map(int,(stdin.readline().strip().split()))) n list(map(int,(stdin.readline().strip().split()))) list map(int,(stdin.readline().strip().split())) map int stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split k int(input()) for x in range(n) for x in range(n) x range(n) range n for x in range(n) int(input()) int input() input w=[int(input()) for x in range(n)] w [int(input()) for x in range(n)] def f(p):
    i=0
    for j in range(k):
        weight=0
        while(weight+w[i]<=p):
            weight+=w[i]
            i+=1
            if i==n:return n
    return i f i=0 i 0 for j in range(k):
        weight=0
        while(weight+w[i]<=p):
            weight+=w[i]
            i+=1
            if i==n:return n
     j range(k) range k weight=0 weight 0 while(weight+w[i]<=p):
            weight+=w[i]
            i+=1
            if i==n:return n
     weight+w[i]<=p weight+w[i] weight w[i] w i p weight+=w[i] weight w[i] w i i+=1 i 1 if i==n:return n
     i==n i n return i i p p left=0 left 0 right=10**9+1 right 10**9+1 10**9 10 9 1 mid=right//2 mid right//2 right 2 while(True):
    length=f(mid)
    if length==n:
        l=f(mid-1)
        if length==l:
            right=mid
            mid=(right+left)//2
        else:
            print(mid)
            exit()
    if length>n:
        right=mid
        mid=(right+left)//2
    if length<n:
        left=mid
        mid=(right+left)//2 True length=f(mid) length f(mid) f mid if length==n:
        l=f(mid-1)
        if length==l:
            right=mid
            mid=(right+left)//2
        else:
            print(mid)
            exit()
     length==n length n l=f(mid-1) l f(mid-1) f mid-1 mid 1 if length==l:
            right=mid
            mid=(right+left)//2
        else:
            print(mid)
            exit()
     length==l length l right=mid right mid mid=(right+left)//2 mid (right+left)//2 right+left right left 2 print(mid) print mid exit() exit if length>n:
        right=mid
        mid=(right+left)//2
     length>n length n right=mid right mid mid=(right+left)//2 mid (right+left)//2 right+left right left 2 if length<n:
        left=mid
        mid=(right+left)//2 length<n length n left=mid left mid mid=(right+left)//2 mid (right+left)//2 right+left right left 2 def f(p):
    i=0
    for j in range(k):
        weight=0
        while(weight+w[i]<=p):
            weight+=w[i]
            i+=1
            if i==n:return n
    return i def f(p):
    i=0
    for j in range(k):
        weight=0
        while(weight+w[i]<=p):
            weight+=w[i]
            i+=1
            if i==n:return n
    return i f mid=(right+left)//2 (right+left)//2 mid left=0 0 left length=f(mid) f(mid) length mid=right//2 right//2 mid right=mid mid right mid=(right+left)//2 (right+left)//2 mid l=f(mid-1) f(mid-1) l left=mid mid left n,k=list(map(int,(stdin.readline().strip().split()))) list(map(int,(stdin.readline().strip().split()))) n k=list(map(int,(stdin.readline().strip().split()))) list(map(int,(stdin.readline().strip().split()))) k right=mid mid right w=[int(input()) for x in range(n)] [int(input()) for x in range(n)] w mid=(right+left)//2 (right+left)//2 mid right=10**9+1 10**9+1 right
from sys import stdin
import sys
import math
n,k=list(map(int,(stdin.readline().strip().split())))
w=[int(input()) for x in range(n)]
def f(p):
    i=0
    for j in range(k):
        weight=0
        while(weight+w[i]<=p):
            weight+=w[i]
            i+=1
            if i==n:return n
    return i
left=0
right=10**9+1
mid=right//2
while(True):
    length=f(mid)
    if length==n:
        l=f(mid-1)
        if length==l:
            right=mid
            mid=(right+left)//2
        else:
            print(mid)
            exit()
    if length>n:
        right=mid
        mid=(right+left)//2
    if length<n:
        left=mid
        mid=(right+left)//2
