#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache
setrecursionlimit(10**6)
input=stdin.readline

n,k=map(int,input().split())
w=[int(input().rstrip()) for _ in range(n)]
l,r=0,10**9
while l<r:
    m=(l+r)//2
    loop=0
    ch=False
    for i in range(k):
        noww=0
        while loop<n:
            if noww+w[loop]<=m:
                noww+=w[loop]
                loop+=1
            else: break
        else:
            ch=True
    if ch: r=m
    else: l=m+1
    #print(m,l,r)
print(l) from collections import Counter,deque from sys import stdin,setrecursionlimit setrecursionlimit(10**6) setrecursionlimit 10**6 10 6 input=stdin.readline input stdin.readline stdin readline n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k int(input().rstrip()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip w=[int(input().rstrip()) for _ in range(n)] w [int(input().rstrip()) for _ in range(n)] l,r=0,10**9 l 0 r 10**9 10 9 while l<r:
    m=(l+r)//2
    loop=0
    ch=False
    for i in range(k):
        noww=0
        while loop<n:
            if noww+w[loop]<=m:
                noww+=w[loop]
                loop+=1
            else: break
        else:
            ch=True
    if ch: r=m
    else: l=m+1
    #print(m,l,r) l<r l r m=(l+r)//2 m (l+r)//2 l+r l r 2 loop=0 loop 0 ch=False ch False for i in range(k):
        noww=0
        while loop<n:
            if noww+w[loop]<=m:
                noww+=w[loop]
                loop+=1
            else: break
        else:
            ch=True
     i range(k) range k noww=0 noww 0 while loop<n:
            if noww+w[loop]<=m:
                noww+=w[loop]
                loop+=1
            else: break
        else:
            ch=True
     loop<n loop n if noww+w[loop]<=m:
                noww+=w[loop]
                loop+=1
            else: break
         noww+w[loop]<=m noww+w[loop] noww w[loop] w loop m noww+=w[loop] noww w[loop] w loop loop+=1 loop 1 ch=True ch True if ch: r=m
    else: l=m+1
    #print(m,l,r) ch print(l) print l r=0,10**9 10**9 r l,r=0,10**9 0 l input=stdin.readline stdin.readline input m=(l+r)//2 (l+r)//2 m noww+=w[loop] w[loop] noww ch=False False ch loop+=1 1 loop ch=True True ch loop=0 0 loop noww=0 0 noww w=[int(input().rstrip()) for _ in range(n)] [int(input().rstrip()) for _ in range(n)] w n,k=map(int,input().split()) map(int,input().split()) n k=map(int,input().split()) map(int,input().split()) k
#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache
setrecursionlimit(10**6)
input=stdin.readline

n,k=map(int,input().split())
w=[int(input().rstrip()) for _ in range(n)]
l,r=0,10**9
while l<r:
    m=(l+r)//2
    loop=0
    ch=False
    for i in range(k):
        noww=0
        while loop<n:
            if noww+w[loop]<=m:
                noww+=w[loop]
                loop+=1
            else: break
        else:
            ch=True
    if ch: r=m
    else: l=m+1
    #print(m,l,r)
print(l)
