def check(T, p, n, k):
    i = 0
    
    for j in range(k):
        s = 0
       
        while(s+T[i] <= p):
            s += T[i]
            i += 1
            if i == n:
                return n
    
    return i

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

left, right = 0, 100000 * 10000

while(right - left > 1):
    mid = int((left + right) / 2)
    if (check(T, mid, n, k) >= n):
        right = mid
    else:
        left = mid

print(right) def check(T, p, n, k):
    i = 0
    
    for j in range(k):
        s = 0
       
        while(s+T[i] <= p):
            s += T[i]
            i += 1
            if i == n:
                return n
    
    return i check i = 0 i 0 for j in range(k):
        s = 0
       
        while(s+T[i] <= p):
            s += T[i]
            i += 1
            if i == n:
                return n
    
     j range(k) range k s = 0 s 0 while(s+T[i] <= p):
            s += T[i]
            i += 1
            if i == n:
                return n
    
     s+T[i] <= p s+T[i] s T[i] T i p s += T[i] s T[i] T i i += 1 i 1 if i == n:
                return n
    
     i == n i n return n n return i i T T p p n n k k int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n, k = [int(x) for x in input().split()] n [int(x) for x in input().split()] k T = [] T [] for i in range(n):
    T.append(int(input())) i range(n) range n T.append(int(input())) T.append T append int(input()) int input() input left, right = 0, 100000 * 10000 left 0 right 100000 * 10000 100000 10000 while(right - left > 1):
    mid = int((left + right) / 2)
    if (check(T, mid, n, k) >= n):
        right = mid
    else:
        left = mid right - left > 1 right - left right left 1 mid = int((left + right) / 2) mid int((left + right) / 2) int (left + right) / 2 left + right left right 2 if (check(T, mid, n, k) >= n):
        right = mid
    else:
        left = mid check(T, mid, n, k) >= n check(T, mid, n, k) check T mid n k n right = mid right mid left = mid left mid print(right) print right left = mid mid left right = mid mid right right = 0, 100000 * 10000 100000 * 10000 right n, k = [int(x) for x in input().split()] [int(x) for x in input().split()] n k = [int(x) for x in input().split()] [int(x) for x in input().split()] k def check(T, p, n, k):
    i = 0
    
    for j in range(k):
        s = 0
       
        while(s+T[i] <= p):
            s += T[i]
            i += 1
            if i == n:
                return n
    
    return i def check(T, p, n, k):
    i = 0
    
    for j in range(k):
        s = 0
       
        while(s+T[i] <= p):
            s += T[i]
            i += 1
            if i == n:
                return n
    
    return i check T = [] [] T left, right = 0, 100000 * 10000 0 left mid = int((left + right) / 2) int((left + right) / 2) mid
def check(T, p, n, k):
    i = 0
    
    for j in range(k):
        s = 0
       
        while(s+T[i] <= p):
            s += T[i]
            i += 1
            if i == n:
                return n
    
    return i

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

left, right = 0, 100000 * 10000

while(right - left > 1):
    mid = int((left + right) / 2)
    if (check(T, mid, n, k) >= n):
        right = mid
    else:
        left = mid

print(right)