def chkp(P):
    global n, k, w
    i = 0
    for j in range(k):
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if(i == n):
                return n
    return i

def binary_search():
    l = 0
    r = 100000 * 10000
    while r - l > 1:
        c = (l+r) // 2
        v =  chkp(c)
        if(v >= n):
            r = c
        else:
            l = c
    return r

n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
res = binary_search()
print(int(res)) def chkp(P):
    global n, k, w
    i = 0
    for j in range(k):
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if(i == n):
                return n
    return i chkp global n, k, w i = 0 i 0 for j in range(k):
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if(i == n):
                return n
     j range(k) range k s = 0 s 0 while s + w[i] <= P:
            s += w[i]
            i += 1
            if(i == n):
                return n
     s + w[i] <= P s + w[i] s w[i] w i P 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 P P def binary_search():
    l = 0
    r = 100000 * 10000
    while r - l > 1:
        c = (l+r) // 2
        v =  chkp(c)
        if(v >= n):
            r = c
        else:
            l = c
    return r binary_search l = 0 l 0 r = 100000 * 10000 r 100000 * 10000 100000 10000 while r - l > 1:
        c = (l+r) // 2
        v =  chkp(c)
        if(v >= n):
            r = c
        else:
            l = c
     r - l > 1 r - l r l 1 c = (l+r) // 2 c (l+r) // 2 l+r l r 2 v =  chkp(c) v chkp(c) chkp c if(v >= n):
            r = c
        else:
            l = c
     v >= n v n r = c r c l = c l c return r r 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)] res = binary_search() res binary_search() binary_search print(int(res)) print int(res) int res def binary_search():
    l = 0
    r = 100000 * 10000
    while r - l > 1:
        c = (l+r) // 2
        v =  chkp(c)
        if(v >= n):
            r = c
        else:
            l = c
    return r def binary_search():
    l = 0
    r = 100000 * 10000
    while r - l > 1:
        c = (l+r) // 2
        v =  chkp(c)
        if(v >= n):
            r = c
        else:
            l = c
    return r binary_search n, k = map(int, input().split()) map(int, input().split()) n res = binary_search() binary_search() res w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w def chkp(P):
    global n, k, w
    i = 0
    for j in range(k):
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if(i == n):
                return n
    return i def chkp(P):
    global n, k, w
    i = 0
    for j in range(k):
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if(i == n):
                return n
    return i chkp k = map(int, input().split()) map(int, input().split()) k
def chkp(P):
    global n, k, w
    i = 0
    for j in range(k):
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if(i == n):
                return n
    return i

def binary_search():
    l = 0
    r = 100000 * 10000
    while r - l > 1:
        c = (l+r) // 2
        v =  chkp(c)
        if(v >= n):
            r = c
        else:
            l = c
    return r

n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
res = binary_search()
print(int(res))
