from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
W = [int(stdin.readline().rstrip()) for _ in range(N)]

def check(P):
    i = 0
    for _ in range(K):
        s = 0
        while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
    return i

def solver():
    mid, l, u = 0, 0, 100000*10000
    while u-l > 1:
        mid = (l+u)//2
        v = check(mid)
        if v >= N:
            u = mid
        else:
            l = mid
    return u
    
print(solver()) from sys import stdin int(_) for _ in stdin.readline().rstrip().split() for _ in stdin.readline().rstrip().split() _ stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split for _ in stdin.readline().rstrip().split() int(_) int _ N, K = [int(_) for _ in stdin.readline().rstrip().split()] N [int(_) for _ in stdin.readline().rstrip().split()] K int(stdin.readline().rstrip()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(stdin.readline().rstrip()) int stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip W = [int(stdin.readline().rstrip()) for _ in range(N)] W [int(stdin.readline().rstrip()) for _ in range(N)] def check(P):
    i = 0
    for _ in range(K):
        s = 0
        while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
    return i check i = 0 i 0 for _ in range(K):
        s = 0
        while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
     _ range(K) range K s = 0 s 0 while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
     s+W[i] <= P s+W[i] s W[i] W i P s += W[i] s W[i] W i i += 1 i 1 if i == N:
                return N
     i == N i N return N N return i i P P def solver():
    mid, l, u = 0, 0, 100000*10000
    while u-l > 1:
        mid = (l+u)//2
        v = check(mid)
        if v >= N:
            u = mid
        else:
            l = mid
    return u
     solver mid, l, u = 0, 0, 100000*10000 mid 0 l 0 u 100000*10000 100000 10000 while u-l > 1:
        mid = (l+u)//2
        v = check(mid)
        if v >= N:
            u = mid
        else:
            l = mid
     u-l > 1 u-l u l 1 mid = (l+u)//2 mid (l+u)//2 l+u l u 2 v = check(mid) v check(mid) check mid if v >= N:
            u = mid
        else:
            l = mid
     v >= N v N u = mid u mid l = mid l mid return u u print(solver()) print solver() solver K = [int(_) for _ in stdin.readline().rstrip().split()] [int(_) for _ in stdin.readline().rstrip().split()] K W = [int(stdin.readline().rstrip()) for _ in range(N)] [int(stdin.readline().rstrip()) for _ in range(N)] W def solver():
    mid, l, u = 0, 0, 100000*10000
    while u-l > 1:
        mid = (l+u)//2
        v = check(mid)
        if v >= N:
            u = mid
        else:
            l = mid
    return u
     def solver():
    mid, l, u = 0, 0, 100000*10000
    while u-l > 1:
        mid = (l+u)//2
        v = check(mid)
        if v >= N:
            u = mid
        else:
            l = mid
    return u
     solver N, K = [int(_) for _ in stdin.readline().rstrip().split()] [int(_) for _ in stdin.readline().rstrip().split()] N def check(P):
    i = 0
    for _ in range(K):
        s = 0
        while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
    return i def check(P):
    i = 0
    for _ in range(K):
        s = 0
        while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
    return i check
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
W = [int(stdin.readline().rstrip()) for _ in range(N)]

def check(P):
    i = 0
    for _ in range(K):
        s = 0
        while s+W[i] <= P:
            s += W[i]
            i += 1
            if i == N:
                return N
    return i

def solver():
    mid, l, u = 0, 0, 100000*10000
    while u-l > 1:
        mid = (l+u)//2
        v = check(mid)
        if v >= N:
            u = mid
        else:
            l = mid
    return u
    
print(solver())
