def can(l, k, p):
    s, a = 0, 0
    for li in l:
        if li > p: return False
        s += li

        if s > p:
            s = li
            k -= 1
        if k <= 0: return False
        
    return True

def bi(array, k, l, r):
    m = (l + r) // 2
    if l > r:
        return max(l, r)
    b = can(array, k, m)
    if b:
        return bi(array, k, l, m-1)
    else:
        return bi(array, k, m+1, r)
        
    
n, k = map(int, input().split())
l = [0] * n
for i in range(n):
    l[i] = int(input())
    
p = sum(l)
print(bi(l, k, 0, p)) def can(l, k, p):
    s, a = 0, 0
    for li in l:
        if li > p: return False
        s += li

        if s > p:
            s = li
            k -= 1
        if k <= 0: return False
        
    return True can s, a = 0, 0 s 0 a 0 for li in l:
        if li > p: return False
        s += li

        if s > p:
            s = li
            k -= 1
        if k <= 0: return False
        
     li l if li > p: return False
         li > p li p s += li s li if s > p:
            s = li
            k -= 1
         s > p s p s = li s li k -= 1 k 1 if k <= 0: return False
        
     k <= 0 k 0 return True True l l k k p p def bi(array, k, l, r):
    m = (l + r) // 2
    if l > r:
        return max(l, r)
    b = can(array, k, m)
    if b:
        return bi(array, k, l, m-1)
    else:
        return bi(array, k, m+1, r)
        
     bi m = (l + r) // 2 m (l + r) // 2 l + r l r 2 if l > r:
        return max(l, r)
     l > r l r return max(l, r) max(l, r) max l r b = can(array, k, m) b can(array, k, m) can array k m if b:
        return bi(array, k, l, m-1)
    else:
        return bi(array, k, m+1, r)
        
     b return bi(array, k, l, m-1) bi(array, k, l, m-1) bi array k l m-1 m 1 return bi(array, k, m+1, r) bi(array, k, m+1, r) bi array k m+1 m 1 r array array k k l l r r n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k l = [0] * n l [0] * n [0] 0 n for i in range(n):
    l[i] = int(input())
     i range(n) range n l[i] = int(input()) l[i] l i int(input()) int input() input p = sum(l) p sum(l) sum l print(bi(l, k, 0, p)) print bi(l, k, 0, p) bi l k 0 p p = sum(l) sum(l) p def bi(array, k, l, r):
    m = (l + r) // 2
    if l > r:
        return max(l, r)
    b = can(array, k, m)
    if b:
        return bi(array, k, l, m-1)
    else:
        return bi(array, k, m+1, r)
        
     def bi(array, k, l, r):
    m = (l + r) // 2
    if l > r:
        return max(l, r)
    b = can(array, k, m)
    if b:
        return bi(array, k, l, m-1)
    else:
        return bi(array, k, m+1, r)
        
     bi def can(l, k, p):
    s, a = 0, 0
    for li in l:
        if li > p: return False
        s += li

        if s > p:
            s = li
            k -= 1
        if k <= 0: return False
        
    return True def can(l, k, p):
    s, a = 0, 0
    for li in l:
        if li > p: return False
        s += li

        if s > p:
            s = li
            k -= 1
        if k <= 0: return False
        
    return True can k = map(int, input().split()) map(int, input().split()) k l = [0] * n [0] * n l n, k = map(int, input().split()) map(int, input().split()) n
def can(l, k, p):
    s, a = 0, 0
    for li in l:
        if li > p: return False
        s += li

        if s > p:
            s = li
            k -= 1
        if k <= 0: return False
        
    return True

def bi(array, k, l, r):
    m = (l + r) // 2
    if l > r:
        return max(l, r)
    b = can(array, k, m)
    if b:
        return bi(array, k, l, m-1)
    else:
        return bi(array, k, m+1, r)
        
    
n, k = map(int, input().split())
l = [0] * n
for i in range(n):
    l[i] = int(input())
    
p = sum(l)
print(bi(l, k, 0, p))
