import math

_=list(map(int,input().split()))
n,k=_[0],_[1]
W=[]
for i in range(n):
    W.append(int(input()))

def n_cal(num_track,weights,threshold):
    numbers_=0
    for i in range(num_track): #each tracktor
        sum_=0
        while sum_<=threshold and numbers_<=len(weights)-1: #each tracktor's capacity
            sum_+=weights[numbers_] #each tracktor's weight
            if sum_<=threshold:numbers_+=1
            else:pass
    return numbers_

minimum_=max(W)
maximum_=sum(W)
P=range(minimum_,maximum_+1)

left=0;right=len(P)
mid=math.floor((left+right)/2)
while left<right:
    if n_cal(k,W,P[mid])<n:
        left=mid+1
    elif n==n_cal(k,W,P[mid]) and n==n_cal(k,W,P[mid-1]):
        right=mid
    else:break
    mid=math.floor((left+right)/2)
print(P[mid]) import math math _=list(map(int,input().split())) _ list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split n,k=_[0],_[1] n _[0] _ 0 k _[1] _ 1 W=[] W [] for i in range(n):
    W.append(int(input())) i range(n) range n W.append(int(input())) W.append W append int(input()) int input() input def n_cal(num_track,weights,threshold):
    numbers_=0
    for i in range(num_track): #each tracktor
        sum_=0
        while sum_<=threshold and numbers_<=len(weights)-1: #each tracktor's capacity
            sum_+=weights[numbers_] #each tracktor's weight
            if sum_<=threshold:numbers_+=1
            else:pass
    return numbers_ n_cal numbers_=0 numbers_ 0 for i in range(num_track): #each tracktor
        sum_=0
        while sum_<=threshold and numbers_<=len(weights)-1: #each tracktor's capacity
            sum_+=weights[numbers_] #each tracktor's weight
            if sum_<=threshold:numbers_+=1
            else:pass
     i range(num_track) range num_track sum_=0 sum_ 0 while sum_<=threshold and numbers_<=len(weights)-1: #each tracktor's capacity
            sum_+=weights[numbers_] #each tracktor's weight
            if sum_<=threshold:numbers_+=1
            else:pass
     sum_<=threshold and numbers_<=len(weights)-1 sum_<=threshold sum_ threshold numbers_<=len(weights)-1 numbers_ len(weights)-1 len(weights) len weights 1 sum_+=weights[numbers_] sum_ weights[numbers_] weights numbers_ if sum_<=threshold:numbers_+=1
            else:pass
     sum_<=threshold sum_ threshold return numbers_ numbers_ num_track num_track weights weights threshold threshold minimum_=max(W) minimum_ max(W) max W maximum_=sum(W) maximum_ sum(W) sum W P=range(minimum_,maximum_+1) P range(minimum_,maximum_+1) range minimum_ maximum_+1 maximum_ 1 left=0 left 0 right=len(P) right len(P) len P mid=math.floor((left+right)/2) mid math.floor((left+right)/2) math.floor math floor (left+right)/2 left+right left right 2 while left<right:
    if n_cal(k,W,P[mid])<n:
        left=mid+1
    elif n==n_cal(k,W,P[mid]) and n==n_cal(k,W,P[mid-1]):
        right=mid
    else:break
    mid=math.floor((left+right)/2) left<right left right if n_cal(k,W,P[mid])<n:
        left=mid+1
    elif n==n_cal(k,W,P[mid]) and n==n_cal(k,W,P[mid-1]):
        right=mid
    else:break
     n_cal(k,W,P[mid])<n n_cal(k,W,P[mid]) n_cal k W P[mid] P mid n left=mid+1 left mid+1 mid 1 elif n==n_cal(k,W,P[mid]) and n==n_cal(k,W,P[mid-1]):
        right=mid
     n==n_cal(k,W,P[mid]) and n==n_cal(k,W,P[mid-1]) n==n_cal(k,W,P[mid]) n n_cal(k,W,P[mid]) n_cal k W P[mid] P mid n==n_cal(k,W,P[mid-1]) n n_cal(k,W,P[mid-1]) n_cal k W P[mid-1] P mid-1 mid 1 right=mid right mid mid=math.floor((left+right)/2) mid math.floor((left+right)/2) math.floor math floor (left+right)/2 left+right left right 2 print(P[mid]) print P[mid] P mid n,k=_[0],_[1] _[0] n minimum_=max(W) max(W) minimum_ right=len(P) len(P) right k=_[0],_[1] _[1] k _=list(map(int,input().split())) list(map(int,input().split())) _ P=range(minimum_,maximum_+1) range(minimum_,maximum_+1) P right=mid mid right left=0 0 left left=mid+1 mid+1 left W=[] [] W mid=math.floor((left+right)/2) math.floor((left+right)/2) mid mid=math.floor((left+right)/2) math.floor((left+right)/2) mid def n_cal(num_track,weights,threshold):
    numbers_=0
    for i in range(num_track): #each tracktor
        sum_=0
        while sum_<=threshold and numbers_<=len(weights)-1: #each tracktor's capacity
            sum_+=weights[numbers_] #each tracktor's weight
            if sum_<=threshold:numbers_+=1
            else:pass
    return numbers_ def n_cal(num_track,weights,threshold):
    numbers_=0
    for i in range(num_track): #each tracktor
        sum_=0
        while sum_<=threshold and numbers_<=len(weights)-1: #each tracktor's capacity
            sum_+=weights[numbers_] #each tracktor's weight
            if sum_<=threshold:numbers_+=1
            else:pass
    return numbers_ n_cal maximum_=sum(W) sum(W) maximum_
import math

_=list(map(int,input().split()))
n,k=_[0],_[1]
W=[]
for i in range(n):
    W.append(int(input()))

def n_cal(num_track,weights,threshold):
    numbers_=0
    for i in range(num_track): #each tracktor
        sum_=0
        while sum_<=threshold and numbers_<=len(weights)-1: #each tracktor's capacity
            sum_+=weights[numbers_] #each tracktor's weight
            if sum_<=threshold:numbers_+=1
            else:pass
    return numbers_

minimum_=max(W)
maximum_=sum(W)
P=range(minimum_,maximum_+1)

left=0;right=len(P)
mid=math.floor((left+right)/2)
while left<right:
    if n_cal(k,W,P[mid])<n:
        left=mid+1
    elif n==n_cal(k,W,P[mid]) and n==n_cal(k,W,P[mid-1]):
        right=mid
    else:break
    mid=math.floor((left+right)/2)
print(P[mid])
