from sys import stdin

def Check(P):
    j = 0
    for _ in range(k):
        s = 0
        while s + W[j] <= P:
            s += W[j]
            j += 1
            if j == n:
                return j
    return j

def Solve():
    l = 0
    r = 100000 * 100000
    while r - l > 1:
        m = (l + r) // 2
        v = Check(m)
        if v == n:
            r = m
        else:
            l = m
    return r

n, k = map(int, stdin.readline().split())
W = [int(x) for x in stdin.readlines()]

print(Solve()) from sys import stdin def Check(P):
    j = 0
    for _ in range(k):
        s = 0
        while s + W[j] <= P:
            s += W[j]
            j += 1
            if j == n:
                return j
    return j Check j = 0 j 0 for _ in range(k):
        s = 0
        while s + W[j] <= P:
            s += W[j]
            j += 1
            if j == n:
                return j
     _ range(k) range k s = 0 s 0 while s + W[j] <= P:
            s += W[j]
            j += 1
            if j == n:
                return j
     s + W[j] <= P s + W[j] s W[j] W j P s += W[j] s W[j] W j j += 1 j 1 if j == n:
                return j
     j == n j n return j j return j j P P def Solve():
    l = 0
    r = 100000 * 100000
    while r - l > 1:
        m = (l + r) // 2
        v = Check(m)
        if v == n:
            r = m
        else:
            l = m
    return r Solve l = 0 l 0 r = 100000 * 100000 r 100000 * 100000 100000 100000 while r - l > 1:
        m = (l + r) // 2
        v = Check(m)
        if v == n:
            r = m
        else:
            l = m
     r - l > 1 r - l r l 1 m = (l + r) // 2 m (l + r) // 2 l + r l r 2 v = Check(m) v Check(m) Check m if v == n:
            r = m
        else:
            l = m
     v == n v n r = m r m l = m l m return r r n, k = map(int, stdin.readline().split()) n map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split k int(x) for x in stdin.readlines() for x in stdin.readlines() x stdin.readlines() stdin.readlines stdin readlines for x in stdin.readlines() int(x) int x W = [int(x) for x in stdin.readlines()] W [int(x) for x in stdin.readlines()] print(Solve()) print Solve() Solve k = map(int, stdin.readline().split()) map(int, stdin.readline().split()) k W = [int(x) for x in stdin.readlines()] [int(x) for x in stdin.readlines()] W n, k = map(int, stdin.readline().split()) map(int, stdin.readline().split()) n def Solve():
    l = 0
    r = 100000 * 100000
    while r - l > 1:
        m = (l + r) // 2
        v = Check(m)
        if v == n:
            r = m
        else:
            l = m
    return r def Solve():
    l = 0
    r = 100000 * 100000
    while r - l > 1:
        m = (l + r) // 2
        v = Check(m)
        if v == n:
            r = m
        else:
            l = m
    return r Solve def Check(P):
    j = 0
    for _ in range(k):
        s = 0
        while s + W[j] <= P:
            s += W[j]
            j += 1
            if j == n:
                return j
    return j def Check(P):
    j = 0
    for _ in range(k):
        s = 0
        while s + W[j] <= P:
            s += W[j]
            j += 1
            if j == n:
                return j
    return j Check
from sys import stdin

def Check(P):
    j = 0
    for _ in range(k):
        s = 0
        while s + W[j] <= P:
            s += W[j]
            j += 1
            if j == n:
                return j
    return j

def Solve():
    l = 0
    r = 100000 * 100000
    while r - l > 1:
        m = (l + r) // 2
        v = Check(m)
        if v == n:
            r = m
        else:
            l = m
    return r

n, k = map(int, stdin.readline().split())
W = [int(x) for x in stdin.readlines()]

print(Solve())
