n, k = map(int, input().split())
w = []
for _ in range(n):
    w.append(int(input()))
imax = 100000 * 1000000
imin = 1
while imin < imax:
    imid = (imin + imax) // 2
    track_num = 0
    current = 0
    for i in range(n):
        if w[i] > imid:
            track_num = k
            break
        elif w[i] + current > imid:
            track_num += 1
            current = w[i]
        else:
            current += w[i]
    if track_num < k:
        imax = imid
    else:
        imin = imid + 1
print(imax) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k w = [] w [] for _ in range(n):
    w.append(int(input())) _ range(n) range n w.append(int(input())) w.append w append int(input()) int input() input imax = 100000 * 1000000 imax 100000 * 1000000 100000 1000000 imin = 1 imin 1 while imin < imax:
    imid = (imin + imax) // 2
    track_num = 0
    current = 0
    for i in range(n):
        if w[i] > imid:
            track_num = k
            break
        elif w[i] + current > imid:
            track_num += 1
            current = w[i]
        else:
            current += w[i]
    if track_num < k:
        imax = imid
    else:
        imin = imid + 1 imin < imax imin imax imid = (imin + imax) // 2 imid (imin + imax) // 2 imin + imax imin imax 2 track_num = 0 track_num 0 current = 0 current 0 for i in range(n):
        if w[i] > imid:
            track_num = k
            break
        elif w[i] + current > imid:
            track_num += 1
            current = w[i]
        else:
            current += w[i]
     i range(n) range n if w[i] > imid:
            track_num = k
            break
        elif w[i] + current > imid:
            track_num += 1
            current = w[i]
        else:
            current += w[i]
     w[i] > imid w[i] w i imid track_num = k track_num k break elif w[i] + current > imid:
            track_num += 1
            current = w[i]
         w[i] + current > imid w[i] + current w[i] w i current imid track_num += 1 track_num 1 current = w[i] current w[i] w i current += w[i] current w[i] w i if track_num < k:
        imax = imid
    else:
        imin = imid + 1 track_num < k track_num k imax = imid imax imid imin = imid + 1 imin imid + 1 imid 1 print(imax) print imax imax = 100000 * 1000000 100000 * 1000000 imax current += w[i] w[i] current imax = imid imid imax w = [] [] w n, k = map(int, input().split()) map(int, input().split()) n current = w[i] w[i] current k = map(int, input().split()) map(int, input().split()) k track_num = 0 0 track_num track_num = k k track_num imin = 1 1 imin imin = imid + 1 imid + 1 imin current = 0 0 current track_num += 1 1 track_num imid = (imin + imax) // 2 (imin + imax) // 2 imid
n, k = map(int, input().split())
w = []
for _ in range(n):
    w.append(int(input()))
imax = 100000 * 1000000
imin = 1
while imin < imax:
    imid = (imin + imax) // 2
    track_num = 0
    current = 0
    for i in range(n):
        if w[i] > imid:
            track_num = k
            break
        elif w[i] + current > imid:
            track_num += 1
            current = w[i]
        else:
            current += w[i]
    if track_num < k:
        imax = imid
    else:
        imin = imid + 1
print(imax)