MAX = 100000

def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
    return i

def solve():
    left = 0
    right = MAX * 10000
    while (right - left > 1):
        mid = (left + right) / 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right

n, k = map(int, raw_input().split())
T = []

for i in range(n):
    T.append(input())

ans = solve()

print ans MAX = 100000 MAX 100000 def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
    return i check i = 0 i 0 for j in range(k):
        s = 0
        while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
     j range(k) range k s = 0 s 0 while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
     s + T[i] <= p s + T[i] s T[i] T i p s = s + T[i] s s + T[i] s T[i] T i i = i + 1 i i + 1 i 1 if i == n:
                return n
     i == n i n return n n return i i p p def solve():
    left = 0
    right = MAX * 10000
    while (right - left > 1):
        mid = (left + right) / 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right solve left = 0 left 0 right = MAX * 10000 right MAX * 10000 MAX 10000 while (right - left > 1):
        mid = (left + right) / 2
        v = check(mid)
        if v >= 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 v = check(mid) v check(mid) check mid if v >= n:
            right = mid
        else:
            left = mid
     v >= n v n right = mid right mid left = mid left mid return right right n, k = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split k T = [] T [] for i in range(n):
    T.append(input()) i range(n) range n T.append(input()) T.append T append input() input ans = solve() ans solve() solve print T = [] [] T n, k = map(int, raw_input().split()) map(int, raw_input().split()) n MAX = 100000 100000 MAX def solve():
    left = 0
    right = MAX * 10000
    while (right - left > 1):
        mid = (left + right) / 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right def solve():
    left = 0
    right = MAX * 10000
    while (right - left > 1):
        mid = (left + right) / 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right solve def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
    return i def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
    return i check ans = solve() solve() ans k = map(int, raw_input().split()) map(int, raw_input().split()) k
MAX = 100000

def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
    return i

def solve():
    left = 0
    right = MAX * 10000
    while (right - left > 1):
        mid = (left + right) / 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right

n, k = map(int, raw_input().split())
T = []

for i in range(n):
    T.append(input())

ans = solve()

print ans