n, k = map(int, input().split())
a = [int(input()) for i in range(n)]

def check(a, p):
    if max(a) > p:
        return False
    else:
        tr = 0
        count = 1
        for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
        if count > k:
            return False
        else:
            return True
Min = 0
Max = max(a) * (n // k + 1)

while Min + 1 < Max:
    if check(a, (Min + Max) // 2) == True:
        Max = (Min + Max) // 2
    else:
        Min = (Min + Max) // 2
print(Max)
 n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input a = [int(input()) for i in range(n)] a [int(input()) for i in range(n)] def check(a, p):
    if max(a) > p:
        return False
    else:
        tr = 0
        count = 1
        for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
        if count > k:
            return False
        else:
            return True check if max(a) > p:
        return False
    else:
        tr = 0
        count = 1
        for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
        if count > k:
            return False
        else:
            return True max(a) > p max(a) max a p return False False tr = 0 tr 0 count = 1 count 1 for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
         i a tr += i tr i if tr > p:
                count += 1
                tr = i
         tr > p tr p count += 1 count 1 tr = i tr i if count > k:
            return False
        else:
            return True count > k count k return False False return True True a a p p Min = 0 Min 0 Max = max(a) * (n // k + 1) Max max(a) * (n // k + 1) max(a) max a n // k + 1 n // k n k 1 while Min + 1 < Max:
    if check(a, (Min + Max) // 2) == True:
        Max = (Min + Max) // 2
    else:
        Min = (Min + Max) // 2 Min + 1 < Max Min + 1 Min 1 Max if check(a, (Min + Max) // 2) == True:
        Max = (Min + Max) // 2
    else:
        Min = (Min + Max) // 2 check(a, (Min + Max) // 2) == True check(a, (Min + Max) // 2) check a (Min + Max) // 2 Min + Max Min Max 2 True Max = (Min + Max) // 2 Max (Min + Max) // 2 Min + Max Min Max 2 Min = (Min + Max) // 2 Min (Min + Max) // 2 Min + Max Min Max 2 print(Max) print Max n, k = map(int, input().split()) map(int, input().split()) n Max = (Min + Max) // 2 (Min + Max) // 2 Max Min = 0 0 Min Max = max(a) * (n // k + 1) max(a) * (n // k + 1) Max def check(a, p):
    if max(a) > p:
        return False
    else:
        tr = 0
        count = 1
        for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
        if count > k:
            return False
        else:
            return True def check(a, p):
    if max(a) > p:
        return False
    else:
        tr = 0
        count = 1
        for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
        if count > k:
            return False
        else:
            return True check a = [int(input()) for i in range(n)] [int(input()) for i in range(n)] a k = map(int, input().split()) map(int, input().split()) k Min = (Min + Max) // 2 (Min + Max) // 2 Min
n, k = map(int, input().split())
a = [int(input()) for i in range(n)]

def check(a, p):
    if max(a) > p:
        return False
    else:
        tr = 0
        count = 1
        for i in a:
            tr += i
            if tr > p:
                count += 1
                tr = i
        if count > k:
            return False
        else:
            return True
Min = 0
Max = max(a) * (n // k + 1)

while Min + 1 < Max:
    if check(a, (Min + Max) // 2) == True:
        Max = (Min + Max) // 2
    else:
        Min = (Min + Max) // 2
print(Max)

