n, k = map(int, input().split())

W = []
for _ in range(n):
    w = int(input())
    W.append(w)
    
Baggages = W[:]
        
def _check(tmp_P):
    num_track = 1
    tmp_sum = 0
    for b in Baggages:
        if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
    return True
    

def check(P):
    i = 0
    for _ in range(k):
        s = 0
        while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
    if i == n:
        return True
    else:
        return False

    
def binary_search(max_r):
    left = 0
    right = max_r
    
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) == True:
            right = mid
        else:
            left = mid
    return right
            
max_p = sum(Baggages)+1
ans = binary_search(max_p)
print(ans)

#print(check(4))
#print(check(5))
#print(check(6))
#print(check(7))
    
    

    

    
 n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k W = [] W [] for _ in range(n):
    w = int(input())
    W.append(w)
     _ range(n) range n w = int(input()) w int(input()) int input() input W.append(w) W.append W append w Baggages = W[:] Baggages W[:] W : def _check(tmp_P):
    num_track = 1
    tmp_sum = 0
    for b in Baggages:
        if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
    return True
     _check num_track = 1 num_track 1 tmp_sum = 0 tmp_sum 0 for b in Baggages:
        if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
     b Baggages if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
     tmp_sum+b <= tmp_P tmp_sum+b tmp_sum b tmp_P tmp_sum += b tmp_sum b num_track += 1 num_track 1 tmp_sum = b tmp_sum b if num_track > k:
                return False
     num_track > k num_track k return False False return True True tmp_P tmp_P def check(P):
    i = 0
    for _ in range(k):
        s = 0
        while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
    if i == n:
        return True
    else:
        return False

     check i = 0 i 0 for _ in range(k):
        s = 0
        while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
     _ range(k) range k s = 0 s 0 while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
     s+Baggages[i] <= P s+Baggages[i] s Baggages[i] Baggages i P s += Baggages[i] s Baggages[i] Baggages i i += 1 i 1 if i >= n:
                return True
     i >= n i n return True True if i == n:
        return True
    else:
        return False

     i == n i n return True True return False False P P def binary_search(max_r):
    left = 0
    right = max_r
    
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) == True:
            right = mid
        else:
            left = mid
    return right
             binary_search left = 0 left 0 right = max_r right max_r while right-left > 1:
        mid = (left+right)//2
        if check(mid) == True:
            right = mid
        else:
            left = mid
     right-left > 1 right-left right left 1 mid = (left+right)//2 mid (left+right)//2 left+right left right 2 if check(mid) == True:
            right = mid
        else:
            left = mid
     check(mid) == True check(mid) check mid True right = mid right mid left = mid left mid return right right max_r max_r max_p = sum(Baggages)+1 max_p sum(Baggages)+1 sum(Baggages) sum Baggages 1 ans = binary_search(max_p) ans binary_search(max_p) binary_search max_p print(ans) print ans Baggages = W[:] W[:] Baggages w = int(input()) int(input()) w def check(P):
    i = 0
    for _ in range(k):
        s = 0
        while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
    if i == n:
        return True
    else:
        return False

     def check(P):
    i = 0
    for _ in range(k):
        s = 0
        while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
    if i == n:
        return True
    else:
        return False

     check n, k = map(int, input().split()) map(int, input().split()) n def binary_search(max_r):
    left = 0
    right = max_r
    
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) == True:
            right = mid
        else:
            left = mid
    return right
             def binary_search(max_r):
    left = 0
    right = max_r
    
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) == True:
            right = mid
        else:
            left = mid
    return right
             binary_search k = map(int, input().split()) map(int, input().split()) k max_p = sum(Baggages)+1 sum(Baggages)+1 max_p W = [] [] W def _check(tmp_P):
    num_track = 1
    tmp_sum = 0
    for b in Baggages:
        if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
    return True
     def _check(tmp_P):
    num_track = 1
    tmp_sum = 0
    for b in Baggages:
        if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
    return True
     _check ans = binary_search(max_p) binary_search(max_p) ans
n, k = map(int, input().split())

W = []
for _ in range(n):
    w = int(input())
    W.append(w)
    
Baggages = W[:]
        
def _check(tmp_P):
    num_track = 1
    tmp_sum = 0
    for b in Baggages:
        if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
    return True
    

def check(P):
    i = 0
    for _ in range(k):
        s = 0
        while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
    if i == n:
        return True
    else:
        return False

    
def binary_search(max_r):
    left = 0
    right = max_r
    
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) == True:
            right = mid
        else:
            left = mid
    return right
            
max_p = sum(Baggages)+1
ans = binary_search(max_p)
print(ans)

#print(check(4))
#print(check(5))
#print(check(6))
#print(check(7))
    
    

    

    

