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

for i in range(n):
    w_in.append(int(input()))


def alloc(p):
    load = 0
    track = 1
    for w in w_in:
        if w > p:
            return False
        if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
    return True


def binsearch():
    upper = sum(w_in)
    lower = max(w_in)
    while(upper != lower):
        mid = int((upper + lower) / 2)
        if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
    return upper
print(binsearch()) n, k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k w_in = list() w_in list() list for i in range(n):
    w_in.append(int(input())) i range(n) range n w_in.append(int(input())) w_in.append w_in append int(input()) int input() input def alloc(p):
    load = 0
    track = 1
    for w in w_in:
        if w > p:
            return False
        if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
    return True alloc load = 0 load 0 track = 1 track 1 for w in w_in:
        if w > p:
            return False
        if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
     w w_in if w > p:
            return False
         w > p w p return False False if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
     load + w <= p load + w load w p load += w load w load = w load w track += 1 track 1 if track > k:
                return False
     track > k track k return False False return True True p p def binsearch():
    upper = sum(w_in)
    lower = max(w_in)
    while(upper != lower):
        mid = int((upper + lower) / 2)
        if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
    return upper binsearch upper = sum(w_in) upper sum(w_in) sum w_in lower = max(w_in) lower max(w_in) max w_in while(upper != lower):
        mid = int((upper + lower) / 2)
        if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
     upper != lower upper lower mid = int((upper + lower) / 2) mid int((upper + lower) / 2) int (upper + lower) / 2 upper + lower upper lower 2 if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
     alloc(mid) alloc mid upper = mid upper mid lower = mid + 1 lower mid + 1 mid 1 return upper upper print(binsearch()) print binsearch() binsearch k = map(int,input().split()) map(int,input().split()) k def binsearch():
    upper = sum(w_in)
    lower = max(w_in)
    while(upper != lower):
        mid = int((upper + lower) / 2)
        if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
    return upper def binsearch():
    upper = sum(w_in)
    lower = max(w_in)
    while(upper != lower):
        mid = int((upper + lower) / 2)
        if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
    return upper binsearch w_in = list() list() w_in def alloc(p):
    load = 0
    track = 1
    for w in w_in:
        if w > p:
            return False
        if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
    return True def alloc(p):
    load = 0
    track = 1
    for w in w_in:
        if w > p:
            return False
        if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
    return True alloc n, k = map(int,input().split()) map(int,input().split()) n
n, k = map(int,input().split())
w_in = list()

for i in range(n):
    w_in.append(int(input()))


def alloc(p):
    load = 0
    track = 1
    for w in w_in:
        if w > p:
            return False
        if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
    return True


def binsearch():
    upper = sum(w_in)
    lower = max(w_in)
    while(upper != lower):
        mid = int((upper + lower) / 2)
        if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
    return upper
print(binsearch())