n,k = map(int,input().split())
w = [int(input()) for i in range(n)]
def f(x):
    i = 0
    for j in range(k):
        s = 0
        while s+w[i] <= x:
            s += w[i]
            i+=1
            if i == n:
                return n
    return i

def bin_search(left,right):
    while right - left > 1:
        mid = (left + right) // 2
        if f(mid) == n:
            right = mid
        else:
            left = mid
    return right

print(bin_search(0,10**9)) n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input w = [int(input()) for i in range(n)] w [int(input()) for i in range(n)] def f(x):
    i = 0
    for j in range(k):
        s = 0
        while s+w[i] <= x:
            s += w[i]
            i+=1
            if i == n:
                return n
    return i f i = 0 i 0 for j in range(k):
        s = 0
        while s+w[i] <= x:
            s += w[i]
            i+=1
            if i == n:
                return n
     j range(k) range k s = 0 s 0 while s+w[i] <= x:
            s += w[i]
            i+=1
            if i == n:
                return n
     s+w[i] <= x s+w[i] s w[i] w i x s += w[i] s w[i] w i i+=1 i 1 if i == n:
                return n
     i == n i n return n n return i i x x def bin_search(left,right):
    while right - left > 1:
        mid = (left + right) // 2
        if f(mid) == n:
            right = mid
        else:
            left = mid
    return right bin_search while right - left > 1:
        mid = (left + right) // 2
        if f(mid) == n:
            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 f(mid) == n:
            right = mid
        else:
            left = mid
     f(mid) == n f(mid) f mid n right = mid right mid left = mid left mid return right right left left right right print(bin_search(0,10**9)) print bin_search(0,10**9) bin_search 0 10**9 10 9 k = map(int,input().split()) map(int,input().split()) k n,k = map(int,input().split()) map(int,input().split()) n w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w def f(x):
    i = 0
    for j in range(k):
        s = 0
        while s+w[i] <= x:
            s += w[i]
            i+=1
            if i == n:
                return n
    return i def f(x):
    i = 0
    for j in range(k):
        s = 0
        while s+w[i] <= x:
            s += w[i]
            i+=1
            if i == n:
                return n
    return i f def bin_search(left,right):
    while right - left > 1:
        mid = (left + right) // 2
        if f(mid) == n:
            right = mid
        else:
            left = mid
    return right def bin_search(left,right):
    while right - left > 1:
        mid = (left + right) // 2
        if f(mid) == n:
            right = mid
        else:
            left = mid
    return right bin_search
n,k = map(int,input().split())
w = [int(input()) for i in range(n)]
def f(x):
    i = 0
    for j in range(k):
        s = 0
        while s+w[i] <= x:
            s += w[i]
            i+=1
            if i == n:
                return n
    return i

def bin_search(left,right):
    while right - left > 1:
        mid = (left + right) // 2
        if f(mid) == n:
            right = mid
        else:
            left = mid
    return right

print(bin_search(0,10**9))
