n, k = map(int, input().split())
ww = [int(input()) for _ in range(n)]
def chk(p):
    c = 1
    s = 0
    for w in ww:
        if w > p:
            return False
        if s + w <= p:
            s += w
        else:
            c += 1
            s = w
        if c > k:
            return False
    return True
def search(l, r):
    if r - l < 10:
        for i in range(l, r):
            if chk(i):
                return i
    m = (l + r) // 2
    if chk(m):
        return search(l, m + 1)
    else:
        return search(m, r)
print(search(0, 2 ** 30)) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input ww = [int(input()) for _ in range(n)] ww [int(input()) for _ in range(n)] def chk(p):
    c = 1
    s = 0
    for w in ww:
        if w > p:
            return False
        if s + w <= p:
            s += w
        else:
            c += 1
            s = w
        if c > k:
            return False
    return True chk c = 1 c 1 s = 0 s 0 for w in ww:
        if w > p:
            return False
        if s + w <= p:
            s += w
        else:
            c += 1
            s = w
        if c > k:
            return False
     w ww if w > p:
            return False
         w > p w p return False False if s + w <= p:
            s += w
        else:
            c += 1
            s = w
         s + w <= p s + w s w p s += w s w c += 1 c 1 s = w s w if c > k:
            return False
     c > k c k return False False return True True p p def search(l, r):
    if r - l < 10:
        for i in range(l, r):
            if chk(i):
                return i
    m = (l + r) // 2
    if chk(m):
        return search(l, m + 1)
    else:
        return search(m, r) search if r - l < 10:
        for i in range(l, r):
            if chk(i):
                return i
     r - l < 10 r - l r l 10 for i in range(l, r):
            if chk(i):
                return i
     i range(l, r) range l r if chk(i):
                return i
     chk(i) chk i return i i m = (l + r) // 2 m (l + r) // 2 l + r l r 2 if chk(m):
        return search(l, m + 1)
    else:
        return search(m, r) chk(m) chk m return search(l, m + 1) search(l, m + 1) search l m + 1 m 1 return search(m, r) search(m, r) search m r l l r r print(search(0, 2 ** 30)) print search(0, 2 ** 30) search 0 2 ** 30 2 30 def chk(p):
    c = 1
    s = 0
    for w in ww:
        if w > p:
            return False
        if s + w <= p:
            s += w
        else:
            c += 1
            s = w
        if c > k:
            return False
    return True def chk(p):
    c = 1
    s = 0
    for w in ww:
        if w > p:
            return False
        if s + w <= p:
            s += w
        else:
            c += 1
            s = w
        if c > k:
            return False
    return True chk ww = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] ww n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k def search(l, r):
    if r - l < 10:
        for i in range(l, r):
            if chk(i):
                return i
    m = (l + r) // 2
    if chk(m):
        return search(l, m + 1)
    else:
        return search(m, r) def search(l, r):
    if r - l < 10:
        for i in range(l, r):
            if chk(i):
                return i
    m = (l + r) // 2
    if chk(m):
        return search(l, m + 1)
    else:
        return search(m, r) search
n, k = map(int, input().split())
ww = [int(input()) for _ in range(n)]
def chk(p):
    c = 1
    s = 0
    for w in ww:
        if w > p:
            return False
        if s + w <= p:
            s += w
        else:
            c += 1
            s = w
        if c > k:
            return False
    return True
def search(l, r):
    if r - l < 10:
        for i in range(l, r):
            if chk(i):
                return i
    m = (l + r) // 2
    if chk(m):
        return search(l, m + 1)
    else:
        return search(m, r)
print(search(0, 2 ** 30))