n,k = map(int,input().split())
s = []
for i in range(n):
    s.append(int(input()))

def f(P):
    v = 0
    for j in range(k):
        a = 0
        while(a+s[v]<=P):
            a += s[v]
            v+=1
            if v==n:
                return v
    return v

l = 0
r = 10**9
while l!=r:
    mid = (l+r)//2
    c = f(mid)
    if c>=n:
        r = mid
    else:
        l = mid+1   
print(r)             n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k s = [] s [] for i in range(n):
    s.append(int(input())) i range(n) range n s.append(int(input())) s.append s append int(input()) int input() input def f(P):
    v = 0
    for j in range(k):
        a = 0
        while(a+s[v]<=P):
            a += s[v]
            v+=1
            if v==n:
                return v
    return v f v = 0 v 0 for j in range(k):
        a = 0
        while(a+s[v]<=P):
            a += s[v]
            v+=1
            if v==n:
                return v
     j range(k) range k a = 0 a 0 while(a+s[v]<=P):
            a += s[v]
            v+=1
            if v==n:
                return v
     a+s[v]<=P a+s[v] a s[v] s v P a += s[v] a s[v] s v v+=1 v 1 if v==n:
                return v
     v==n v n return v v return v v P P l = 0 l 0 r = 10**9 r 10**9 10 9 while l!=r:
    mid = (l+r)//2
    c = f(mid)
    if c>=n:
        r = mid
    else:
        l = mid+1    l!=r l r mid = (l+r)//2 mid (l+r)//2 l+r l r 2 c = f(mid) c f(mid) f mid if c>=n:
        r = mid
    else:
        l = mid+1    c>=n c n r = mid r mid l = mid+1 l mid+1 mid 1 print(r) print r l = mid+1 mid+1 l n,k = map(int,input().split()) map(int,input().split()) n r = 10**9 10**9 r mid = (l+r)//2 (l+r)//2 mid s = [] [] s k = map(int,input().split()) map(int,input().split()) k l = 0 0 l c = f(mid) f(mid) c r = mid mid r def f(P):
    v = 0
    for j in range(k):
        a = 0
        while(a+s[v]<=P):
            a += s[v]
            v+=1
            if v==n:
                return v
    return v def f(P):
    v = 0
    for j in range(k):
        a = 0
        while(a+s[v]<=P):
            a += s[v]
            v+=1
            if v==n:
                return v
    return v f
n,k = map(int,input().split())
s = []
for i in range(n):
    s.append(int(input()))

def f(P):
    v = 0
    for j in range(k):
        a = 0
        while(a+s[v]<=P):
            a += s[v]
            v+=1
            if v==n:
                return v
    return v

l = 0
r = 10**9
while l!=r:
    mid = (l+r)//2
    c = f(mid)
    if c>=n:
        r = mid
    else:
        l = mid+1   
print(r)            
